26
loading...
This website collects cookies to deliver better user experience
useState
or useReducer
is useful, not everything should be placed within it. A lot of new developers struggle with this very concept. They do not know when to put something in the state and when not to.useState
and/or useReducer
hook to manage the state inside it. That way, you are deciding where the state lives and you are handling how to update it and where exactly you wish to use it.array.map
method. Keys must be unique so that React can handle proper tracking of that element or component. If you were to use the index as a key, that key can be a duplicate in some cases, which should be avoided. .map
and use the index as keys. Furthermore, imagine adding to the middle or removing an item from the middle of the array. Key will end up being the same as before, and React will assume it is the same identical element/component as before.useEffect
once when the component mounts.useMemo
or useCallback
and even PureComponents
. Developers need to be very focused and implement memoization with proper care because otherwise, it can break memoization one by one.any
, never
and unknown
. never
in positions where there will not or should not be a value.unknown
where there will be a value, but it might have any type.any
if you really need an unsafe escape hatch.