wsmd / react-use-form-state

📄 React hook for managing forms and inputs state

Home Page:http://react-use-form-state.now.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The initial value for input "*******" is missing.

agonzalezcr opened this issue · comments

Hi there,

First of all thanks a lof for this amazing library. I have a question and not sure if I'm doing something wrong. But I'm using the {raw} type and keep getting the:

The initial value for input "inputName" is missing. Custom inputs controlled with raw() are expected to have an initial value provided to useFormState(). To prevent React from treating this input as uncontrolled, an empty string will be used

My form state looks like:

const [formState, { raw }] = useFormState({ inputName : input.initialValue || "" });

And my custom component looks like:

<CustomComponent {...raw({ name: 'inputName', validate: myValidateFunc })} />

I have tried passing the value after the validate attribute, but I keep getting the same error.

Any clues ?

Hi @agonzalezcr - any chance you could provide a working example that replicates the issue?

Here's a template that you can fork: https://codesandbox.io/s/smoosh-night-q3h8i?expanddevtools=1