-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What's the replacement for ReactNode, ReactType, and ReactInstance? #151
Comments
In Fable.React 5 we've tried too simplify the interfaces as they were translated from the React Typescript definitions because they were quite complicated. Looking at the samples you kindly provided the equivalences seem to be:
type MenuProps =
| AnchorEl of ReactElement
| [<CompiledName("anchorEl")>] AnchorElType of ReactElementType |
Thanks for the quick reply! What is actually Also, |
It's true that the generic makes it difficult to create a prop accepting any kind of // In fable-material-ui
type MaterialProp =
| Component of ReactElementType
..
// Usage
let view (props: {| title: string |}) =
h1 [] [str props.title]
let menuProps =
[ Component (ReactElementType.ofFunction view) ] |
Thanks! Great to have the non-generic one. Given a component from a 3rd party library, how would I get a |
@cmeeren You could just use something like: let inline bigCalendar (props : BigCalendarProps list) : ReactElement =
ofImport "default" "react-big-calendar" (JsInterop.keyValueList CaseRules.LowerFirst props) [] This is what I use in all my bindings and it works. I am not sure why you would need to call |
@MangelMaxime For an example, check the MUI Input API, specifically the function TextMaskCustom(props) {
... // component implementation
}
...
class FormattedInputs extends React.Component {
...
render() {
...
return (
...
<Input
...
inputComponent={TextMaskCustom}
/>
...
}
}
Are you saying I still don't need |
@cmeeren Ah this is the first time I this kind of code. Then I don't know sorry 😅 React is really cool but sometimes it's really too permissive. I mean there are so many ways and hacks possible to write a component. ^^ |
Just import it as // Check the documentation of the component to know if you should import the default or a named member
// See https://fable.io/docs/interacting.html#importing-javascript-code
let BigCalendar: ReactElementType<BigCalendarProps> = importDefault "react-big-calendar" |
I'm currently making a PR to update Fable.MaterialUI to Fable.Core 3 and Fable.React 5. The API makes use of
ReactNode
,ReactType
, andReactInstance
, none of which are available any longer.Should
ReactElement
be used instead for all of these?If you need more context to answer this question, here are examples in the (original) MaterialUI documentation where the three types are used in the current bindings:
ReactNode
:checkedIcon
action
,avatar
,subheader
,title
primary
andsecondary
ReactType
:component
inputComponent
IconComponent
ReactInstance
:anchorEl
container
The text was updated successfully, but these errors were encountered: