Fork me on GitHub
#helix
<
2021-01-05
>
fsd20:01:33

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.

Derek20:01:41

you need to use the setter-fn

Derek20:01:47

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
lilactown20:01:51

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

fsd20:01:05

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