react.isvalidelement code example
Example 1: react memo
function MyComponent(props) {
}
function areEqual(prevProps, nextProps) {
}
export default React.memo(MyComponent, areEqual);
Example 2: React Children map example
export default class SomeComponent extends React.Component {
render() {
const childrenWithWrapperDiv = React.Children.map(this.props.children, child => {
return (
<div className="some-component-special-class">{child}</div>
);
});
return (
<div className="some-component">
<p>This component has {React.Children.count(this.props.children)} children.</p>
{childrenWithWrapperDiv}
</div>
);
}
}