Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 698 Bytes

README.md

File metadata and controls

28 lines (22 loc) · 698 Bytes

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]);
}