Re-render child components if the parent component has been re-rendered
siarheipashkevich opened this issue · comments
I have structure of the components:
const Parent = () => {
const tailwind = useTailwind();
return <Child childStyle={tailwind('h-full')} />;
};
After each re-render my Parent
component my Child
component will get a new result of the tailwind
calling?
@siarheipashkevich useTailwind
hook returns the context value of the TailwindProvider
which indeed is memoised, so unless and until one of the useMemo
dependencies change, it will return a referentially stable function, but the result value of the tailwind()
will return a new object if the parent re renders. Which i think is the expected behaviour and shouldn't be a hit to performance (correct me if I am wrong).
But just incase it is, I think you can use React.memo
if it really matters