1.0.17 • Published 4 years ago

react-nedux v1.0.17

Weekly downloads
18
License
ISC
Repository
github
Last release
4 years ago

React-Nedux - The next react-redux

typescript version size

The official React bindings for nedux. Performant and flexible.

📦 Installation

npm install react-nedux --save

💻 Usage with examples

NameSourceCodesandbox
✅ Todo Listherehere
🎛 Counterherehere

📜 Documentation

Import

// ES6
import { createStoreHook } from 'react-nedux';

// ES5
var createStoreHook = require('react-nedux').createStoreHook;

createStoreHook(store)

Creates a Nedux hook with the same usage of useState.

argumentrequiredtypedescription
storeStoreThe store created by createStore.

useStore

The useStore hook created by createStoreHook can be used as same as useState.

🎛 Basic Usage

Feel free to test it here.

import * as React from 'react';
import { render } from 'react-dom';
import { createStore } from 'nedux';
import { createStoreHook } from 'react-nedux';

const store = createStore({
  counter: 0,
});

const useStore = createStoreHook(store);

const increment = () => store.set('counter', prev => prev + 1);
const decrement = () => store.set('counter', prev => prev - 1);

const App = () => {
  const [counter] = useStore('counter');

  return (
    <span>
      <p>you've clicked {counter} times</p>
      <button onClick={increment}>+</button>
      <button onClick={decrement}>-</button>
    </span>
  );
};

const rootElement = document.getElementById('root');
render(<App />, rootElement);

🙋🏼 Contributions

All Pull Requests, Issues and Discussions are welcomed !

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago