ts2fable
ts2fable copied to clipboard
Import React Components
Currently react components are not really correctly imported.
Looking a bit through github I found https://github.com/fable-compiler/fable-react/issues/151#issuecomment-484612054
For example, react-popper-tooltip currently generates this
type [<AllowNullLiteral>] IExports =
abstract Tooltip: TooltipStatic
type [<AllowNullLiteral>] Tooltip =
inherit Component<TooltipProps>
abstract componentDidMount: unit -> unit
abstract componentDidUpdate: unit -> unit
abstract componentWillUnmount: unit -> unit
abstract render: unit -> JSX.Element
type [<AllowNullLiteral>] TooltipStatic =
[<Emit "new $0($1...)">] abstract Create: unit -> Tooltip
abstract contextType: React.Context<TypeLiteral_01> with get, set
Better would probably be:
type [<AllowNullLiteral>] IExports =
abstract Tooltip: ReactElementType<TooltipProps>
Edit:
Hm, I don't think I can (easily) create an instance from an ReactElementType in F#, so maybe better generate this:
type [<AllowNullLiteral>] IExports =
abstract Tooltip: TooltipProps -> ReactElement
SyntheticEvent was removed from Fable.React, in most cases MouseEvent should be used.