Skip to content
Discussion options

You must be logged in to vote

Hi,

Thanks for reaching out!

The idiomatic solution for your use case is to use State-derived properties. Thus instead of having:

const imgSrc = van.bind(isOpen, (v) => v ? "open-icon.png" : "close-icon.png");

you can have:

const imgSrc = {deps: [isOpen], f: (v) => v ? "open-icon.png" : "close-icon.png"}

This technique is illustrated in sample app JSON Inspector (code) and Textarea with Autocomplete (code).

btw: I guess onClick should be onclick which is a native property of DOM node.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
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