Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

manchaary/react-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

React utility functions

  1. useStore - React useContext wrapper. Throw an error if Context is empty.

Example:

const { loadData } = useStore(MyStoreContext);
  1. useOutsideClick - Click outside of defined ref (used for closing dropdowns, modals). Removes listener when open is false.

Example:

const ref = useRef(ref)
const [open, setOpen] = useState(false);
const closeHandle = () => setOpen(false);
useOutsideClickClose(open, ref, closeHandle);

return (
  <div ref={ref}>...</div>
);

  1. createProvider - Creates provider component and context for mobx stores.

Example:

const { Context, Provider } = createProvider(MyMobxStore);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published