Skip to content

Multi select / option buttons #273

Answered by Tao-VanJS
HEAVYPOLY asked this question in Q&A
Discussion options

You must be logged in to vote

For the derived state to be reactive to the field updates of the reactive object, you need to "access" the field inside the binding function, instead of accessing the field outside the binding function and pass-in the result into the binding function (see the caveat here).

For your example to work, you need to change the value of setting property into a function and invoke the function inside the binding function of van.derive. That is, the code can be changed into the following:

btw: another thing needs to fix is to change highlight into highlight.val for accessing the value of the state.

const MultiButton = ({ setting, value, text, onclick }) => {
  const highlighted = van.derive(() => (v…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@HEAVYPOLY
Comment options

Answer selected by Tao-VanJS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants