1.0.4 • Published 4 years ago

redux-dispatch-hooks v1.0.4

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

redux-dispatch-hooks

Developer friendly dispatch hooks. Brings mapDispatchToProps like experience.

Installation

npm i -S redux-dispatch-hooks

Setup

If you're using react-redux, you can just wrap your app with react-redux Provider and it will work. Otherwise you can use Provider from this lib:

import React from 'react';
import { Provider } from 'redux-dispatch-hooks';
import { createStore } from 'redux';
import { RootComponent } from './your-root-component-path'

const store = createStore(...);

export const App = () => (
  <Provider store={store}>
    <RootComponent>
  </Provider>
);

Usage

import React from "react";
import { useDispatchMap } = from "redux-dispatch-hooks";
import * as actions from "./actions";

const Comment = ({
  onRemove,
  onShare,
}) => {
  return (
    <div>
      SOME COMMENT
      <div onClick={onRemove}>REMOVE</div>
      <div onClick={onShare}>SHARE</div>
    </div>
  )
};

const CommentContainer = () => {
  const dispatchMap = useDispatchMap({
    onRemove
    onShare
  });
  return (
    <Comment
      {...dispatchMap}
    />
  );
}
1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago