rechex
v1.0.1
Published
<p align="center"> <a href="https://github.com/ar-dehghan-a/rechex"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://github.com/ar-dehghan-a/rechex/raw/master/public/icons/icon128.png"> <img src="https://github.com
Downloads
2
Readme
React Chrome Extension (RECHEX)
RECHEX
will help you to write chrome extensions more easily with React JS
useChromeLocalStorage
To use this hook, just import it and use it like useState
import React from 'react'
import {useChromeLocalStorage} from 'rechex'
const App: React.FC = () => {
const [counter, setCounter, clearCounter] = useChromeLocalStorage('counter', 0)
return (
<>
<div>
<button onClick={() => setCounter(counter + 1)}>Counter: {counter}</button>
</div>
<div>
<button onClick={() => clearCounter()}>Clear local storage</button>
</div>
</>
)
}
Also, by putting the value of true in the third input, you can activate the sync mode so that it receives and applies all the changes at the moment
useChromeLocalStorage('key', 'initValue', true)