我有一个使用钩子useCallback的功能组件。过去几天一切都很好。一切都正常运作。今天我启动了这个应用程序,我有一个错误:
React Hook "useCallback" is called in function "loginPage" which is neither a React function component or a custom React Hook function
这是没有道理的,因为它一直很好。为了调试,我只是删除了页面上的所有代码,只是其中一段代码经过了编辑,甚至只是将一个useCallback模板放在了原来的位置,但仍然一样。
我试图写一个from,但是它抛出了这个错误:
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You m
一切都很好。
问题是当我按下delete按钮时,它会删除但不会立即从表中删除。当我重新加载页面时,它会删除。当我按delete键时,我替换-- localStorage中的学生数组。你的帮助将不胜感激。提前谢谢你。
const history = useHistory();
let student = JSON.parse(localStorage.getItem('student'))
这是用于删除项的函数。
const deleteStudent = (event)=>{
let id = event.currentTarget.id
let students
我有一个在子级和其父级之间传递的props代码:
Parent.js
const defaultState = {
canOperate: false,
// among other states
};
const [state, setState] = useState(defaultState);
// this technique is for avoiding some re-renders in some occasions, I'm using a lot of this way to set the
// state in this Parent compon