Skip to content

Commit 60eef88

Browse files
vbfoxalfonsogarciacaro
authored andcommitted
memoWith
1 parent 13e5d22 commit 60eef88

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/Fable.React/Fable.Helpers.React.fs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,9 +909,22 @@ type PropsEqualityComparison<'props> = 'props -> 'props -> bool
909909
/// component, and reuse the last rendered result.
910910
///
911911
/// By default it will only shallowly compare complex objects in the props object. If you want control over the
912-
/// comparison, you can also provide a custom comparison function as the second argument.
912+
/// comparison, you can use `memoWith`.
913913
[<Import("memo", from="react")>]
914-
let memo<'props> (render: 'props -> ReactElement, areEqual: PropsEqualityComparison<'props> option) : ReactComponentType<'props> =
914+
let memo<'props> (render: 'props -> ReactElement) : ReactComponentType<'props> =
915+
jsNative
916+
917+
/// React.memo is a higher order component. It’s similar to React.PureComponent but for function components instead of
918+
/// classes.
919+
///
920+
/// If your function component renders the same result given the same props, you can wrap it in a call to React.memo
921+
/// for a performance boost in some cases by memoizing the result. This means that React will skip rendering the
922+
/// component, and reuse the last rendered result.
923+
///
924+
/// This version allow you to control the comparison used instead of the default shallow one by provide a custom
925+
/// comparison function as the second argument.
926+
[<Import("memo", from="react")>]
927+
let memoWith<'props> (render: 'props -> ReactElement, areEqual: PropsEqualityComparison<'props>) : ReactComponentType<'props> =
915928
jsNative
916929

917930
/// Create a ReactElement to be rendered from an element type, props and children

0 commit comments

Comments
 (0)