@@ -851,6 +851,14 @@ let inline fn<'P> (f: 'P -> ReactElement) (props: 'P) (children: ReactElement se
851
851
let inline ofImport < 'P > ( importMember : string ) ( importPath : string ) ( props : 'P ) ( children : ReactElement seq ): ReactElement =
852
852
createElement( import importMember importPath, props, children)
853
853
854
+ [<Erase>]
855
+ type ReactElementType < 'props > = interface end
856
+
857
+ [<Erase>]
858
+ type ReactComponentType < 'props > =
859
+ inherit ReactElementType< 'props>
860
+ abstract displayName: string option with get, set
861
+
854
862
#if FABLE_ COMPILER
855
863
/// Alias of `ofString`
856
864
let inline str ( s : string ): ReactElement = unbox s
@@ -878,6 +886,40 @@ let inline ofList (els: ReactElement list): ReactElement = unbox(List.toArray el
878
886
/// Returns an array **from .render() method**
879
887
let inline ofArray ( els : ReactElement array ): ReactElement = unbox els
880
888
889
+ [<RequireQualifiedAccess>]
890
+ module ReactElementType =
891
+ let inline ofComponent < 'comp , 'props , 'state when 'comp :> Component < 'props , 'state >> : ReactComponentType < 'props > =
892
+ unbox jsConstructor< 'comp>
893
+
894
+ let inline ofFunction < 'props > ( f : 'props -> ReactElement ) : ReactComponentType < 'props > =
895
+ unbox f
896
+
897
+ let inline ofHtmlElement < 'props > ( name : string ): ReactElementType < 'props > =
898
+ unbox name
899
+
900
+ /// Create a ReactElement to be rendered from an element type, props and children
901
+ let inline create < 'props > ( comp : ReactElementType < 'props >) ( props : 'props ) ( children : ReactElement seq ): ReactElement =
902
+ createElement( comp, props, children)
903
+
904
+ type PropsEqualityComparison < 'props > = 'props -> 'props -> bool
905
+
906
+ /// React.memo is a higher order component. It’s similar to React.PureComponent but for function components instead of
907
+ /// classes.
908
+ ///
909
+ /// If your function component renders the same result given the same props, you can wrap it in a call to React.memo
910
+ /// for a performance boost in some cases by memoizing the result. This means that React will skip rendering the
911
+ /// component, and reuse the last rendered result.
912
+ ///
913
+ /// By default it will only shallowly compare complex objects in the props object. If you want control over the
914
+ /// comparison, you can also provide a custom comparison function as the second argument.
915
+ [<Import( " memo" , from= " react" ) >]
916
+ let memo < 'props > ( render : 'props -> ReactElement , areEqual : PropsEqualityComparison < 'props > option ) : ReactComponentType < 'props > =
917
+ jsNative
918
+
919
+ /// Create a ReactElement to be rendered from an element type, props and children
920
+ let inline ofElementType < 'props > ( comp : ReactElementType < 'props >) ( props : 'props ) ( children : ReactElement seq ): ReactElement =
921
+ ReactElementType.create comp props children
922
+
881
923
#else
882
924
/// Alias of `ofString`
883
925
let inline str ( s : string ): ReactElement = HTMLNode.Text s :> ReactElement
0 commit comments