How to use the @hookstate/core.StateMemo function in @hookstate/core

To help you get started, we’ve selected a few @hookstate/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github avkonst / hookstate / examples / src / examples / plugin-touched.tsx View on Github external
function ModifiedStatus(props: { state: StateLink }) {
    const touched = useStateLink(props.state,
        // StateMemo is optional:
        // it skips rendering when touched status is not changed
        StateMemo((s) => Touched(s).touched()));
    return <p>
        Last render at: {(new Date()).toISOString()} <br>
        Is whole current state touched: {touched.toString()} <br>
    </p>
}
github avkonst / hookstate / examples / src / examples / plugin-initial.tsx View on Github external
function ModifiedStatus(props: { state: StateLink }) {
    const modified = useStateLink(props.state,
        // StateMemo is optional:
        // it skips rendering when modified status is not changed
        StateMemo((s) =&gt; Initial(s).modified()));
    return <p>
        Last render at: {(new Date()).toISOString()} <br>
        Is whole current state modified (vs the initial): {modified.toString()} <br>
        The <b>initial</b> state: {JSON.stringify(Initial(props.state).get())}
    </p>
}

@hookstate/core

The flexible, fast and extendable state management for React that is based on hooks and state usage tracking.

MIT
Latest version published 2 years ago

Package Health Score

60 / 100
Full package analysis

Similar packages