This is really incredible. I am migrating an application to see its behavior in a real case and only one of the resources is not working, which would be setState ({property: value}). in this case, the return of the state forms me null, getState and setState are not working.
Thanks for feedback! Your error is that you assign the node created by span() method instead of the div() one. Span doesn't have any state and so, you've got null. Simply change the value of your variable, like this:
This is really incredible. I am migrating an application to see its behavior in a real case and only one of the resources is not working, which would be setState ({property: value}). in this case, the return of the state forms me null, getState and setState are not working.
const node = view
.child("div", {
state: { color: "#aaa", change: false },
styles: (node) => ({
color: node.getState("color"),
}),
})
.span("TEXT ONE")
.on("click", (target) => {
node.getState("change");
node.setState({ change: true });
console.log(node.getState("change"));
if (target.target.textContent === "TEXT ONE") {
node.text("TEXT TWO");
} else {
node.text("TEXT ONE");
}
});
Thanks for feedback! Your error is that you assign the node created by
span()
method instead of thediv()
one. Span doesn't have any state and so, you've gotnull
. Simply change the value of your variable, like this:Thanks ! S2
in this case, the state return is null, getState and setState are not working.*