Below is the code:
const Info = (props) => (
<div>
<h1>Info</h1>
<p>The info is: {props.info}</p>
</div>
);
const withAdminWarning = (WrappedComponent) => {
return (props) => (
<div>
<p>This is private info. Please don't share!</p>
<WrappedComponent {...props}/> // why need to use spread operator?
</div>
);
};
const AdminInfo = withAdminWarning(Info);
ReactDOM.render(<AdminInfo info="There are the details" />, document.getElementById('app'));
what I don't understand is, why it has to be :
<WrappedComponent {...props}/>
and I can't pass an object as:
const temp = {info: "There are the details"}
<WrappedComponent temp/>
isn't that {...props} an object too?