helix

https://github.com/Lokeh/helix
Aron 2020-04-19T00:17:18.243800Z

maybe because expects a component/element as a child not a string, have you tried ($ App {} "some string") ?

lilactown 2020-04-19T00:38:57.244Z

what does the first one render?

fabrao 2020-04-19T14:31:58.247400Z

Iยดm trying to figure out how it works about refresh. Is it controlled by defnc as component?

2020-04-19T19:47:13.248200Z

is it possible to use react-hook-form with helix ?

lilactown 2020-04-19T20:18:27.248600Z

you can use any hooks with helix yes

2020-04-19T20:23:59.251800Z

I took a look at its code. Its a ton of code. In cljs side we have schema, malli. I'm interested on the dirty field code, without it every field would appear invalid before having received the focus.

2020-04-19T20:25:51.253200Z

I've tried naivelly using useForm hook without success. Have you used it before ?

lilactown 2020-04-19T20:26:18.253600Z

I have not but i'm reading their docs. should be straight forward if you're familiar with CLJS interop

lilactown 2020-04-19T20:26:26.254Z

what was unsuccessful about your attempt?

2020-04-19T20:28:46.255200Z

I create a useForm object succesfully , I'm failling to use the register method that appears to register the input with useForm

lilactown 2020-04-19T20:29:24.255400Z

okay

2020-04-19T20:32:08.256900Z

I'm not seeing errors or data on handleSubmit

lilactown 2020-04-19T20:32:17.257200Z

^:js {:keys [register
                       handleSubmit
                       watch
                       errors] :as obj} (rhf/useForm)
this looks wrong

lilactown 2020-04-19T20:32:45.258Z

useForm will return a JS object, which can't be destructured

2020-04-19T20:32:55.258400Z

oh, sorry, thats working. I'm using [applied-science.js-interop :as j] to interop

lilactown 2020-04-19T20:33:47.259500Z

ah I didn't see the j/let

2020-04-19T20:33:47.259600Z

I've printed the object on console and its there.

2020-04-19T20:34:30.260Z

No problem, I've discovered this today ๐Ÿ™‚ nice one

2020-04-19T20:36:00.261400Z

It appears by the docs that register is a invocation , so I've called it, on the 1st createElement input that does not depend on helix, and on the second via helix macro

lilactown 2020-04-19T20:36:57.261800Z

it looks pretty much correct to me

lilactown 2020-04-19T20:37:11.262200Z

do you see a difference between using .createElement vs. helix.dom/input?

2020-04-19T20:38:24.263600Z

no the createElement was me doubting you ๐Ÿ™‚ but your code does not pick attributes , it handles all of them equally .

lilactown 2020-04-19T20:39:39.264Z

are the inputs not registered at all?

2020-04-19T20:40:00.264300Z

if I dont see data or errors I suppose no

2020-04-19T20:40:43.265100Z

by the way, how do you handle this kind of form behaviour with helix ?

lilactown 2020-04-19T20:41:16.265700Z

helix isn't special, so using something like react-hook-form seems like the best approach

lilactown 2020-04-19T20:41:22.265900Z

I haven't done a lot of complex forms with helix yet

lilactown 2020-04-19T20:42:32.266900Z

I guess I would check to ensure that the register function is real, I'm not sure how to dig into this since I don't have a project setup

2020-04-19T20:42:35.267100Z

As far I understand the snippet I've sent you is not helix dependant

lilactown 2020-04-19T20:42:53.267400Z

if you want to push a minimal repro I could try and look at it later

Aron 2020-04-19T20:43:13.267800Z

from the example alone in their readme I wouldn't even consider react-hook-form

lilactown 2020-04-19T20:47:33.270400Z

seems fine to me

2020-04-19T20:47:34.270500Z

If I could mix malli with react-hook-form or have the machinery of dirty fields to trigger validation it would be usefull. trying to use react-hook-form first.

lilactown 2020-04-19T20:49:01.271500Z

I'm not super familiar with malli, but my guess is if you want to integrate the two, you'll want to transform your malli schema into something react-hook-form understands

Aron 2020-04-19T20:49:28.272400Z

I've done lots of form validation and these simple conditionals are straight road to spaghetti-town ๐Ÿ™‚

lilactown 2020-04-19T20:49:33.272500Z

just a hunch, haven't played with either one

Aron 2020-04-19T20:51:20.273500Z

https://github.com/react-hook-form/react-hook-form/blob/master/examples/validationSchema.tsx see how they just dump the errors instead of actually showing the appropriate error for the appropriate field?

Aron 2020-04-19T20:51:24.273800Z

it's very hard

Aron 2020-04-19T20:52:40.275900Z

to do proper validation, I am not bashing on them, just know what you subscribe for, check all the examples, make sure you know if you have edge cases. For example, collection of fields having to be validated at once, or conditional requirements, or nested collections with requireds...

2020-04-19T20:52:44.276100Z

@lilactown you can pass a function to validate on the register call. that would open the possilibity to invoke cljs

2020-04-19T20:54:15.276300Z

<input
  name="test"
  ref={
    register({
      validate: value => value === '1'
    })
  }
/>

Aron 2020-04-19T20:56:29.278200Z

Now imagine a form where you specify names of people and their salaries and the form is valid of their average salary is above a certain limit.

lilactown 2020-04-19T20:58:40.278800Z

sure I bet you can dispatch based on what errors are occurring and their relative priority

lilactown 2020-04-19T21:01:48.279900Z

@geraldodev if you push an example project I can try and look at it later today or tmorrow. I have to leave for a bit :sheepy:

2020-04-19T21:02:39.280300Z

@lilactown thank you for the help