Fork me on GitHub

Hi there, I am working on a frontend application which involves Helix and I needed help it has this in the ns

[helix.hooks :as hooks]
(let [ [show-items] (hooks/use-state false)]) I have a navbar which has button, on click it suppose to invert this show-items. if show-item is false, :onclick it will be true;
{:onclick #(not show-items)}
it gives me an error saying that Uncaught Type-error show_item. call is not a function. My goal is to when I click on the button it changes that state and shows of all the items.


you need to use the setter-fn


the hook returns the wrapped value and a setter

🙌 3
Emmanuel John20:01:28

show-items is not a function but the state. I think you want

(let [[visible set-visible] (hooks/use-state false)])
And then:
{:onclick #(set-visible not)}
To toggle it I think

🙌 3

#(set-visible not) I think is what they want


Thanks guys for your quick response I was able to get it working using

(let [[visible set-visible] (hooks/use-state false)])
#(set-visible not)  I appreciate the help! 🙌:skin-tone-2:

👍 3