Dynamic Updating
arthurgeron opened this issue · comments
Arthur Geron commented
So, does S.js automatically watches for changes on S objects inside DOM?
For example, I believe something like this should work:
var icon = 'fas fa-check'
var iconData = S.data(icon)
const loggedInLabel = S.root(() =>
<label class={iconData()}/>
)
document.body.appendChild(loggedInLabel)
setTimeout(() => {icon = 'fas fa-cross'}, 1000)
But even if I assign the value of iconData
again after changing the value of icon
the DOM doesn't update. What am I doing wrong?
Arthur Geron commented
Found out what I was doing wrong, should've updated iconData by calling: iconData(newValue)
instead of a manual way.