Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-redux-hooks

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-redux-hooks

The easiest way to connect redux. Power by react hooks

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

react-redux-hooks

Commitizen friendly Standard Version

The easiest way to connect redux. Power by react hooks.

Getting Started

Connect to redux in component

Just use useRedux. It would return state and dispatch

import { useRedux } from 'react-redux-hooks';

const ToggleButton = () => {
	const [state, dispatch] = useRedux();

	return (
		<button onClick={() => dispatch({ type: 'TOOGLE' })}>
			{state.toggle ? 'Click to close' : 'Click to open'}
		</button>
	);
};
Top level Provider

Just pass redux store with Provider like react-redux.

import React from 'react';
import { createStore } from 'redux';
import { Provider, useRedux } from 'react-redux-hooks';

const store = createStore((state = { toggle: false }, action) => {
	if (action.type === 'TOOGLE') {
		return { toggle: !state.toggle };
	}

	return state;
});

ReactDOM.render(
	<Provider store={store}>
		<ToggleButton />
	</Provider>,
	document.getElementById('content'),
);

Keywords

FAQs

Package last updated on 26 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc