Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabiospampinato/unstated-with-containers
Higher-Order Component for subscribing to containers.
https://github.com/fabiospampinato/unstated-with-containers
containers hoc react unstated
Last synced: 3 months ago
JSON representation
Higher-Order Component for subscribing to containers.
- Host: GitHub
- URL: https://github.com/fabiospampinato/unstated-with-containers
- Owner: fabiospampinato
- License: mit
- Archived: true
- Created: 2018-09-10T18:45:59.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-06T20:06:04.000Z (almost 6 years ago)
- Last Synced: 2024-05-01T12:39:29.456Z (6 months ago)
- Topics: containers, hoc, react, unstated
- Language: TypeScript
- Homepage:
- Size: 22.5 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unstated With Containers
Higher-Order Component for subscribing to containers.
Simplifies your components, removing the need to constantly use the `Subscribe` component.
## Install
```shell
$ npm install --save unstated-with-containers
```## Usage
```tsx
import * as React from 'react';
import {Container} from 'unstated';
import withContainers from 'unstated-with-containers';class CounterContainer extends Container {
state = { value: 0 };
increment = () => {
this.setState({ value: this.state.value + 1 });
}
decrement = () => {
this.setState({ value: this.state.value - 1 });
}
}const App = withContainers ( CounterContainer )(
({ containers: [counter] }) => ( // props.containers[0] === props.container
<>
{counter.state.value}
Increment
Decrement
>
)
);
```## Related
- **[unstated-connect2](https://github.com/fabiospampinato/unstated-connect2)**: Connect containers to components, without sacrificing performance.
- **[unstated-hmr](https://github.com/fabiospampinato/unstated-hmr)**: Preserve containers' states across Hot-Module-Replacements.
- **[unstated-compose](https://github.com/fabiospampinato/unstated-compose)**: Compose multiple containers into one.
- **[unstated-compose-suspense](https://github.com/fabiospampinato/unstated-compose-suspense)**: Add suspend/unsuspend support to `unstated-compose`.
- **[unstated-compose-suspense-middleware](https://github.com/fabiospampinato/unstated-compose-suspense-middleware)**: Add middlewares support to `unstated-compose-suspense`.
- **[unstated-suspense](https://github.com/fabiospampinato/unstated-suspense)**: Suspend/unsuspend updates propagation from your containers.
- **[unstated-suspense-middleware](https://github.com/fabiospampinato/unstated-suspense-middleware)**: Add middlewares support to `unstated-suspense`.## License
MIT © Fabio Spampinato