Skip to content

Instantly share code, notes, and snippets.

@brentsowers1
Created January 26, 2021 13:57
Show Gist options
  • Save brentsowers1/f48a7184a9b6bee7d8344ac3fce00e93 to your computer and use it in GitHub Desktop.
Save brentsowers1/f48a7184a9b6bee7d8344ac3fce00e93 to your computer and use it in GitHub Desktop.
import React from 'react';
import { makeSharedStateHook } from 'make-shared-state-hook';
// Pass in an initial value and you'll get back a function that can be called
// from a component's render method to return the current value and a setter
// function, just like useState!
// You have to pass React as a parameter to avoid React version conflicts
export const useCounter = makeSharedStateHook(React, 0);
export const useLoggedInUser = makeSharedStateHook(React, '');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment