当我以下面的形式使用<Button />
时,它会说
Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of RefFindNode which is inside StrictMode. Instead, add a ref directly to the element you want to reference.
即使我使用了useRef,它仍然显示这个警告。那么我可以在不删除索引文件中的的情况下修复它吗
import React, {useRef} from 'react'
import { Button, Container, Form, Input } from 'semantic-ui-react'
import Layout from '../layout/Layout'
const Login = () => {
let btn = useRef(null)
React.useEffect(() => {
console.log(btn);
})
return (
<Layout>
<Container className="auth-form segment">
<Form>
<Form.Field
label="Email"
control={Input}
placeholder="example@gmail.com"
name="email"
/>
<Form.Field
label="Password"
control={Input}
placeholder="Password"
name="password"
type="password"
/>
<Button content="Login" ref={btn} primary/>
</Form>
</Container>
</Layout>
)
}
export default Login
发布于 2020-11-21 20:27:37
我不认为你能做到这一点。
相反,为什么不这样做(在index.js文件中):
if (process.env.NODE_ENV === 'development') {
return <React.StrictMode><App /></React.StrictMode>;
}
else
{
return <App />;
}
您可以根据自己的意愿使用其他标志...这只是个想法。
https://stackoverflow.com/questions/64782838
复制相似问题