# state-component

> A simple library to access and share React component state from other components.

Latest version **1.0.2** (published 2017-02-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install state-component
pnpm add state-component
yarn add state-component
bun add state-component
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2017-02-21 |
| First published | 2017-02-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | viankakrisna |

## Links

- npm: https://www.npmjs.com/package/state-component
- npm.io page: https://npm.io/package/state-component

## Recent versions

- 1.0.2 (latest) — 2017-02-21
- 1.0.1 — 2017-02-21
- 1.0.0 — 2017-02-21

## README

# state-component
A simple library to access and share React component state from other components.

Usage:

`npm install state-component`
```
import React from "react";
import ReactDOM from "react-dom";
import { setStateContainer, getState, setState } from "state-component";

export default class App extends React.Component {
  constructor(props) {
    super(props);
    setStateContainer(this);
    this.state = {
      counter: 0
    };
  }
  render() {
    return <Counter />;
  }
}

function Counter() {
  return (
    <div>
      <h1>{getState().counter}</h1>
      <button onClick={() => setState({ counter: getState().counter + 1 })}>
        Increment
      </button>
    </div>
  );
}

ReactDOM.render(<App />, document.getElementById("root"));

```

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