0.3.0 • Published 6 years ago

react-iife v0.3.0

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

React-IIFE

A react.js wrapper component that allows you to invoke a function on mount.

Installation

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.

Props

children Node required

The component you are hijacking.

fn Function required

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...

Usage

const instantBake = function() {
    this.setState({ readyToEat: true });
}

<IIFE fn={instantBake}>
    <Cookie />
</IIFE>

Why?

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.

License

ISC

0.3.0

6 years ago

0.2.0

7 years ago

0.1.0

8 years ago

0.5.0

8 years ago

1.5.0

8 years ago

1.0.0

8 years ago