Rerender node on actionCtx update #612
-
I'm trying to controll a class on a node from an action. I have an const toggleState = createSlice(false, 'toggle');
const toggle = createNode<string>(() => {
const id = 'toggle';
return {
id,
schema: (ctx) => {
const myState = ctx.get(toggleState);
toDOM: (node) => ["div", {class: /* Use state here */ }, 0],
},
// ...
};
}, [toggleState]); It works on new renders but not when updated. Trying to force the update with the Tried force update:
How can you accomplish this? I think I'm not understanding how state changes are handled. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Potentially issue with my react |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
toDOM
is only used to create the node. If you want to update it. You need to set something as attr and usetr.setNodeMarkup
to update it.