# react-iife

> A react.js wrapper component that allows you to invoke a function once mounted.

Latest version **0.3.0** (published 2018-04-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-iife
pnpm add react-iife
yarn add react-iife
bun add react-iife
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2018-04-11 |
| First published | 2016-07-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Tom Beute |
| Maintainers | track0x1 |
| Keywords | react, react-component, iife, wrapper |

## Links

- npm: https://www.npmjs.com/package/react-iife
- Repository: https://github.com/track0x1/react-iife
- Homepage: https://github.com/track0x1/react-iife#readme
- Issues: https://github.com/track0x1/react-iife/issues
- npm.io page: https://npm.io/package/react-iife

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2018-04-11
- 0.2.0 — 2017-10-12
- 0.1.0 — 2016-07-18

## README

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...](http://www.ecma-international.org/ecma-262/6.0/index.html#sec-function.prototype.call)*

## Usage

```jsx
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](https://github.com/kadirahq/react-storybook/).

## License

ISC

---
_Source: https://npm.io/package/react-iife · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
