Home > Back-end >  Property input value doesn't exist on type '{}' ts:2339 . The component is .tsx
Property input value doesn't exist on type '{}' ts:2339 . The component is .tsx

Time:06-23

I'm using Form input to clear the value in the text field. But somehow it's not clearing up the input value and shows an error at {inputValue}) with the error message: Property input value doesn't exist on type '{}' ts:2339

            const[inputValue,setInputValue]=useState()
            <Form onChange={({inputValue}) =>setInputValue(inputValue)}>
             <FormInput clearable
                         required
                          type={inputValue}
                             name="search"
                             label="search"
                                            />

`

CodePudding user response:

According to the docs for the onChange event handler, the syntax is:

target.onchange = functionRef;

functionRef is a function name or a function expression. The function receives an Event object as its sole argument.

The argument for your function should be an event, not {inputValue}. You would then get the value with event.target.value. Also, I think that the type prop for the <FormInput /> component should be one of the HTML input types (probably "text"), not the input value.

      <Form onChange={(event) => setInputValue(event.target.value)}>
        <FormInput
          clearable
          required
          type="text"
          name="search"
          label="search"
        />
      </Form>

CodePudding user response:

I tried doing this method. But still, it's throwing an error here.

Can I have any demo on Code sandbox?

  • Related