Skip to content

Bhoos/redux-hooked

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

import { createStore } from 'redux';
import createApplication from 'redux-hooked';

const { useStore, useDispatch, useAction } = createApplication(store);

// Create your application specific hooks and export them
const getConnectionStatus = state => state.status;
export function useConnectionStatus() {
  const { name, age } = useStore((state) => ({
    name: state.name,
    age: state.age,
  }));

  return useStore(getConnectionStatus);
}

const updateUrl = url => ({ type: 'UPDATE_URL', payload: url });
export function useUpdateUrl() {
  return useAction(updateUrl);
}

export function useUserData(id) {
  const { name, age } = useStore(state => state.users[id], [id]);
}

About

The react-redux replacement with hooks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published