https://github.com/codewell/catalyst
React state management made easy
https://github.com/codewell/catalyst
Last synced: 30 days ago
JSON representation
React state management made easy
- Host: GitHub
- URL: https://github.com/codewell/catalyst
- Owner: codewell
- Created: 2019-09-12T10:39:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T10:16:04.000Z (over 3 years ago)
- Last Synced: 2025-01-21T09:56:07.153Z (over 1 year ago)
- Language: JavaScript
- Size: 305 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @codewell/catalyst
React state management made easy
## Installation
```JavaScript
npm install @codewell/catalyst
```
## Basic usage
Supposed to be used with React
```JavaScript
// index.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import catalyst from '@codewell/catalyst';
const { CatalystProvider, CatalystContext } = catalyst(React);
export const catalystContext = CatalystContext; // (*) Make this context available to the rest of the app
ReactDOM.render(
,
document.getElementById('root'),
);
// ...
```
```JavaScript
// App.js
import React, { useContext } from 'react';
import { catalystContext } from './index'; // (*) Exported in index.js
const App = () => {
const { state, dispatch } = useContext(catalystContext);
const action = (event) => {
dispatch({ type: 'SET_AGE', payload: 29 });
};
const inp = (event) => {
dispatch({ type: 'SET_INPUT', payload: event.target.value })
}
return (
{state.name} - {state.age} - {state.input}
Click me
)
};
export default App;
```