$setState
functionSet the state defined by stateConfig on node. Like with `React.useState` you may directly specify the value or use an updater function that will be called with the previous value of the state on that node (which will be the `stateConfig.defaultValue` if not set). When an updater function is used, the node will only be marked dirty if `stateConfig.isEqual(prevValue, value)` is false.
Import
import { $setState } from '@modular/sdk/editor';Notes
- example
- ```ts const toggle = createState('toggle', {parse: Boolean}); // set it direction $setState(node, counterState, true); // use an updater $setState(node, counterState, (prev) => !prev); ```
- returns
- node