Skip to content

Unpacking first-class module directly in default argument of react component fails #7917

@glennsl

Description

@glennsl

Given these definitions:

module M = {
  @react.component
  let make = () => React.null
}
module type S = module type of M

Trying to unpack a first-class module in the argument of a react component:

@react.component
let make = (~component as module(C: S)=module(M)) => <M />

fails with the error

This pattern matches values of type module(S)
  but a pattern was expected which matches values of type option<'a>

The workaround is to unpack the module in the function body instead:

@react.component
let make = (~component=module(M: S)) => {
  module C = unpack(component)
  <C />
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions