const FancyButton = React.forwardRef((props, ref) => (
<buttonref={ref}className="FancyButton">
{props.children}
</button>
));
// You can now get a ref directly to the DOM button:const ref = React.createRef();
<FancyButtonref={ref}>Click me!</FancyButton>;
functionMyComponent(props) {
/* render using props */
}
functionareEqual(prevProps, nextProps) {
/*
return true if passing nextProps to render would return
the same result as passing prevProps to render,
otherwise return false
*/
}
exportdefault React.memo(MyComponent, areEqual);
//Below I use the React.createElement() functiontocreate a virtual DOM
//representation of a <li> element node containing a text node of one (a.k.a.,
//React text) and an idof li1.
var reactNodeLi = React.createElement('li', {id:'li1'}, 'one');