3 ms·
In my opinion React support is progressing quickly but is not fully there yet (definitely more documentation is needed), so for the JSX part the pain is greater
by tga 10y ago
In my opinion React support is progressing quickly but is not fully there yet (definitely more documentation is needed), so for the JSX part the pain is greater than the gain (especially given PropType checking already in React).
As an example, to see what I mean, try to figure out how to write a properly typed Higher Order Component function. Last time I looked at it, this had no direct mention in documentation and only workarounds on StackOverflow.
- amk_ 10y agoIt seems a little strange but you can import the propTypes of the wrapped component (argument to the HOC) into the wrapper and incorporate them into your type checking there.
- tomduncalf 10y agoYou can "pass through" props like so: export var hocFunction: (arg1: any, arg2: any) => <ComponentT>(component: ComponentT) => ComponentT If you want to add new props as a result of the HOC then see the react-redux .d.ts for a few examples: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/react-redux/react-redux.d.ts#L51 https://github.com/DefinitelyTyped/DefinitelyTyped/blob/mast...