reactjs - 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"));
解决方案
使用大写 F,autoFocus
解决了我的问题。
推荐阅读
- node.js - 如何更改 node.js 中 wav 文件的频率?
- c# - CascadeDelete 循环错误
- datetime - 在 Blue Prism 中重置日期或日期时间数据项
- python - 在 pandas/python 中编写函数
- docker - Helm 初始化连接超时参差不齐
- java - VLCJ - 播放列表中的下一个项目在上一个曲目完成后不会开始
- jquery - jQuery slideToggle 移动所有引导列
- python - python匹配字符串并将单词添加到行尾
- spring-data-jpa - 将 Oracle Case Statement 转换为 JPQL 或 JPA 存储库查询?
- c++ - 对象创建错误的 C++ 向量