Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make autofocus on input field when using react-final-form?

I created a form using react-final-form. autofocus is not working. The only solution I know is to use ref feature of React. Can I autofocus the input using react-final-form library?

import React from "react";
import { render } from "react-dom";
import { Form, Field } from "react-final-form";

const App = () => (
  <Form
    render={({}) => (
      <form>
        <Field name="company" component="input" autofocus />
      </form>
    )}
  />
);

render(<App />, document.getElementById("root"));
like image 344
Leon Gilyadov Avatar asked Feb 05 '19 14:02

Leon Gilyadov


1 Answers

Using capital F, autoFocus, solved my problem.

like image 164
Leon Gilyadov Avatar answered Nov 16 '22 19:11

Leon Gilyadov