Skip to content

Instantly share code, notes, and snippets.

@ltsharma
Created June 12, 2020 22:46
Show Gist options
  • Save ltsharma/270ac708d7e1a32b6c377d7776760061 to your computer and use it in GitHub Desktop.
Save ltsharma/270ac708d7e1a32b6c377d7776760061 to your computer and use it in GitHub Desktop.
const AwesomeChild =({text,style})=>{
return(
<Text style={style} >{text}</Text>
)
}
const areEqual=(prevProps,nextProps)=>{
// return false prevProps.text & nextProps.text are not equal.
return prevProps.text===nextProps.text
// else all are equal, no re-render
return true
}
export default React.memo(AwesomeChild,areEqual)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment