admin管理员组文章数量:1022727
React Hook "useDispatch" is called in function "loginForm" which is neither a React function ponent or a custom React Hook function react-hooks/rules-of-hooks
I got this kind of message. Attached code...
import React from 'react'
import { useDispatch} from 'react-redux'
const loginForm = () => {
const dispatch = useDispatch()
return (
<div>lgoinForm</div>
)
}
export default loginForm
React Hook "useDispatch" is called in function "loginForm" which is neither a React function ponent or a custom React Hook function react-hooks/rules-of-hooks
I got this kind of message. Attached code...
import React from 'react'
import { useDispatch} from 'react-redux'
const loginForm = () => {
const dispatch = useDispatch()
return (
<div>lgoinForm</div>
)
}
export default loginForm
Share
Improve this question
edited Jul 8, 2020 at 13:10
skyboyer
23.8k7 gold badges62 silver badges71 bronze badges
asked Jul 8, 2020 at 3:57
Brian WangBrian Wang
831 silver badge8 bronze badges
2 Answers
Reset to default 5Rename loginForm
to LoginForm (ponent should start with a capital letter).
I have tested your code and it works fine after naming the ponent correctly.
Read here and here
You can make the loginForm to useLoginForm it should be a custom hook name starting with use keyword.
React Hook "useDispatch" is called in function "loginForm" which is neither a React function ponent or a custom React Hook function react-hooks/rules-of-hooks
I got this kind of message. Attached code...
import React from 'react'
import { useDispatch} from 'react-redux'
const loginForm = () => {
const dispatch = useDispatch()
return (
<div>lgoinForm</div>
)
}
export default loginForm
React Hook "useDispatch" is called in function "loginForm" which is neither a React function ponent or a custom React Hook function react-hooks/rules-of-hooks
I got this kind of message. Attached code...
import React from 'react'
import { useDispatch} from 'react-redux'
const loginForm = () => {
const dispatch = useDispatch()
return (
<div>lgoinForm</div>
)
}
export default loginForm
Share
Improve this question
edited Jul 8, 2020 at 13:10
skyboyer
23.8k7 gold badges62 silver badges71 bronze badges
asked Jul 8, 2020 at 3:57
Brian WangBrian Wang
831 silver badge8 bronze badges
2 Answers
Reset to default 5Rename loginForm
to LoginForm (ponent should start with a capital letter).
I have tested your code and it works fine after naming the ponent correctly.
Read here and here
You can make the loginForm to useLoginForm it should be a custom hook name starting with use keyword.
本文标签: javascriptI got the problem in using React HookuseDispatch()Stack Overflow
版权声明:本文标题:javascript - I got the problem in using React Hook - useDispatch() - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745504854a2153559.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论