import React from "react";
const withSpecialPower = (Component) => {
return class Wrapper extends React.Component {
render() {
const specialPowerList = [
"be invisible",
"flight",
"see the future",
"read your mind",
];
const specialPower =
specialPowerList[Math.floor(Math.random() * specialPowerList.length)];
return <Component {...this.props} specialPower={specialPower} />;
}
};
};
export default withSpecialPower;