A react.js wrapper component that allows you to invoke a function on mount.
React-IIFE requires React 15 or later.
npm install --save react-iife
React-IIFE uses CommonJS-style requires, which assumes you are using a module bundler like Browserify or Webpack.
The component you are hijacking.
The function you are calling within the context of your child component.
Note: ES6 arrow functions can not be used here because they cause this
argument to be ignored. Read why...
const instantBake = function() {
this.setState({ readyToEat: true });
}
<IIFE fn={instantBake}>
<Cookie />
</IIFE>
Sometimes you may want to force the state of a component or call a function the moment it is mounted. This can be beneficial when demoing components in a sandbox environment like React storybook.
ISC