Skip to content

Instantly share code, notes, and snippets.

@ltsharma
Last active June 13, 2020 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ltsharma/1be2903c9cfa0e6b0003c454f7b18bfb to your computer and use it in GitHub Desktop.
Save ltsharma/1be2903c9cfa0e6b0003c454f7b18bfb to your computer and use it in GitHub Desktop.
export default ()=>{
const [childState, setChildState] = useState(0);
//using useCallback
const awesomeChildListRenderItem = useCallback(
({ item }) => (
<AwesomeChild {...item} onPress={(number)=>{setChildState(number)}} />
),[]);
const awesomeChildListKeyExtractor = useCallback( (item) => `awesome-child-key-${item.id}`,[]);
return(
<FlatList
renderItem={awesomeChildListRenderItem}
keyExtractor={awesomeChildListKeyExtractor}
/>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment