The after code of the first solution is still wrong, because the functions will still have new references every time the functional component is called, since both awesomeChildListRenderItem and awesomeChildListKeyExtractor will be redeclared.
One option to solve this is to declare the functions outside of the component. But in the case of awesomeChildListRenderItem, it is using setChildState, which can only be accessed from within the component scope. In this particular case only, you can use useCallback instead.
That's true with respect to th example i have in this article, in real case, its not fissile to use each & every function outside component, functions will somehow depends on the state & in that case that function will be called.
that's what the dependency array of useCallback does, if there is change in dependency, useCallback returns new function.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The after code of the first solution is still wrong, because the functions will still have new references every time the functional component is called, since both awesomeChildListRenderItem and awesomeChildListKeyExtractor will be redeclared.
One option to solve this is to declare the functions outside of the component. But in the case of awesomeChildListRenderItem, it is using setChildState, which can only be accessed from within the component scope. In this particular case only, you can use useCallback instead.
That's true with respect to th example i have in this article, in real case, its not fissile to use each & every function outside component, functions will somehow depends on the state & in that case that function will be called.
that's what the dependency array of useCallback does, if there is change in dependency, useCallback returns new function.