Last active
June 29, 2019 17:27
-
-
Save nimish-gupta/32f9d4264dfb553e73b25b461a192332 to your computer and use it in GitHub Desktop.
React shouldComponent LifeCycle implemented in Reason React hooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[@react.component] | |
let make = (~name) => name -> React.string; | |
// If you want to shallow compare the props then use React.memo | |
let make = React.memo(make); | |
// If you want to custom compare the nested props then use React.memoCustomCompareProps | |
let deepCompare = (nextProps, currentProps) => nextProps === currentProps; | |
let make = React.memoCustomCompareProps( | |
make, | |
(nextProps, currentProps) => { | |
let result = deepCompare(nextProps, currentProps); | |
result; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you getting error like
This expression's type contains type variables that can't be generalized
try to give your props types in the function definition like