dom-state
v1.0.2
Published
Simple tool to manage JS state with data-attributes
Downloads
2
Readme
DOM-state
Simple library for managing state with a data-attributes
.
npm install dom-state
How to use
import { useDomState } from 'dom-state';
const [getState, setState] = useDomState(element, 0);
button.addEventListener('click', () => {
setState(
(prev) => prev + 1, // or direct value
(newState) => `counter: ${newState}`,
);
});
For more details check source code
How to contribute
If you want to add something, or fix a bug create an issue/PR here, I make sure to check it out.
PS
This is fun project, inspired by article, so use in production at your own risk :)