1

I have the following element

<textarea className='title' autofocus="autoFocus" 
   onChange={(e)=>changeBill(e, 'title')} 
   value={bill?.title} 
   placeholder="Bill Title">
</textarea>

When I open the browser, it gives the following warning:

Warning: Invalid DOM property autofocus. Did you mean autoFocus?

It's still working, but the warning is pretty annoying. I tried "autofocus" and "autoFocus" neither prevents the warning.

1 Answer 1

3

The warning is not about the value of the property, but the property name itself. It should be:

<textarea className='title' autoFocus={true} 
   onChange={(e)=>changeBill(e, 'title')} 
   value={bill?.title} 
   placeholder="Bill Title">
</textarea>

Also the property is accepting true or false. In your example the non empty string is interpreted as true.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.