Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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>
}
function ModifiedStatus(props: { state: StateLink }) {
const modified = useStateLink(props.state,
// StateMemo is optional:
// it skips rendering when modified status is not changed
StateMemo((s) => 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>
}