Fork me on GitHub
#helix
<
2020-11-10
>
dominicm16:11:55

Curious how people are "handling" this:

(let [[error? set-error?] (hooks/use-state false)])
As set-error? is kinda confusing of a name, as it implies it should be a boolean.

ordnungswidrig19:11:01

you can always create a use-errorhook which verifies it’s a boolean

lilactown20:11:43

I go back and forth between preferring set-error or set-error?

lilactown20:11:02

I usually end up refactoring it anyway to a use-reducer anyway once it gets more complex so I don’t really sweat it

Aron21:11:16

error? is a function and set-error? sets the error? predicate?

ordnungswidrig21:11:59

set-error! and error? might be the best

Aron21:11:36

if it sets the error state and not the predicate then set-error. it's set-error! if it mutates too.

ordnungswidrig21:11:16

I used error state to hold the actual error and check with nil? (or some?) if there is an error condition.

ordnungswidrig21:11:23

I trie to stay away from using booleans as much as possible 😛

3
dominicm08:11:41

In my case, the boolean makes sense. It's a very simple toggle for catching when an image fails to load.

3
ordnungswidrig09:11:10

you don’t want to show the reason

dominicm10:11:00

Nope. It's an external vendor who may have an image and if they don't they 404. There's nothing to fix.

ordnungswidrig15:11:35

But there might be a 500?

dominicm18:11:47

If external vendor 500s, I'm still not going to show an error. This image goes directly to their service.

dominicm08:11:41

In my case, the boolean makes sense. It's a very simple toggle for catching when an image fails to load.

3