0.1.5 • Published 3 years ago

redux-hooks-next v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Redux Hooks Next

npm version CodeFactor Codacy Badge

Usage

yarn add redux react-redux

yarn add redux-hooks-next

import { useSelector, useActions, ... } from 'redux-hooks-next'

react-redux

Re-exported useDispatch, useStore from react-redux

useActions(...args)

const mapDispatch = {
    action,
    ...
}

// or

const mapDispatch = [
    action,
    ...
]

function MyScreen() {
  const { action } = useActions(mapDispatch);
  // or
  const [action] = useActions(mapDispatch);
  return <button onClick={action}>click</button>;
}

useSelector(...args)

Here using function shallowEqual for to check if the object inside the selector are still the same. https://redux.js.org/tutorials/fundamentals/part-5-ui-react#selecting-data-in-list-items-by-id

const mapState = (state) => ({
    loading: state.loading,
    ...
});

function MyScreen() {
  const { loading } = useSelector(mapState);
  if (loading) {
    return <p>MyScreen is loading</p>;    
  }
  return <p>MyScreen render</p>;
}
0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago