我最近每次使用钩子时都会收到这个警告,我不知道该怎么办,我确保所述的3个可能原因(重复反应、版本不匹配或钩子规则损坏(都不成立,但我仍然遇到了这个问题
const WelcomeScreen = ({ match, location }) => {
const dispatch = useDispatch();
const state = useSelector(state => state.first)
const id = match.params.id
const { examDetails, loading } = state;
useEffect(() => {
dispatch(getInstituteDetails(id))
}, [dispatch, id])
if (loading)
return <h3>Loading...</h3>
console.log(examDetails);
return {...
它显示在第二行本身
您在react-router-dom
:中使用了错误的API
// not render={WelcomeScreen}
<Route component={WelcomeScreen} path="/" exact />
https://codesandbox.io/s/confident-thompson-ujlxf?file=/src/error.js