use-redux-hook

1.0.2 • Public • Published

use-redux-hook

npm version

A simple react hook to get access to redux store

Pre-requisite

Needs:

  • react > 16.8,
  • react-redux > 6.0.0

Use cases

Currently only way to get access to redux is via the connect HOC. There is no clean way to do it the hook way. This module is a tiny hook that gives out redux store

Install

npm install use-redux-hook

or

yarn add use-redux-hook

Usage

Basic

Simple use case

import React from "react";
import { useReduxStore } from "use-redux-hook";
 
export const ExampleReactComponent = () => {
  const {getState, dispatch} = useReduxStore();
  const { user } = getState();
  return <div> Hello {user.name}</div>;
};

Package Sidebar

Install

npm i use-redux-hook

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

1.43 kB

Total Files

3

Last publish

Collaborators

  • atulanand94