useProjectState()
Using useProjectState in Modularjs
What Is useProjectState?
Example: Project-Specific Counter
module.exports = ({ useProjectState }) => {
const [count, setCount] = useProjectState('countz', 0);
return (
<div>
<h1>Project Counter</h1>
<p>Countz: {count}</p>
<button onClick={() => setCount(countz + 1)}>Increment</button>
</div>
);
};Syntax
Why Use useProjectState?
useGlobalState vs. useProjectState
useGlobalState vs. useProjectStateBest Practices
Summary
Last updated