Passing props from parent to children (React.cloneElement replacement)
Hi team, I’d be grateful for your help.
I have a wrapper component that should play a sound on mouseenter for various JSX elements. To achieve this, I pass an enhanced onMouseEnter handler to each child. I need to use a wrapper rather than adding local logic to each component, since I’ll apply this functionality throughout the app to different types of JSX elements and components.
In React, I implemented it like this: React.Children.map<ReactNode, ReactNode>(children, (child) => { if (!React.isValidElement(child)) return null;