react-share-states-between-tabs
v1.0.2
Published
Library for share persistent state between tabs without redux using a custom hook
Downloads
6
Readme
Description
Library for share persistent state between tabs or windows without redux using a custom hook
Install
npm install react-share-states-between-tabs
OR
yarn add react-share-states-between-tabs
Usage
Add the react-share-states-between-tabs to your main.js for a global import:
import React from 'react'
import useShareStatesBetweenTabs from 'react-share-states-between-tabs'
const App = () => {
const [example, setExample] = useShareStatesBetweenTabs('example', 'iam example');
// You can also use separately if you wish.
// const [example,] = useShareStatesBetweenTabs('example');
// const [, setExample] = useShareStatesBetweenTabs('example');
const handle = (data) => setItems(data);
return (
<h1>{example}</h1>
);
}
Documentation
The hook only receives 2 arguments:
/**
* {String} key name
* {*} value
*/
const [...] = useShareStatesBetweenTabs(KEY_NAME, VALUE);
SIMPLE 😃
Support
[email protected]. You can also send me a direct message on twitter @emanueljcc.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Collaborators
Made with contrib.rocks.
License
MIT License © 2022 Emanuel Castillo