我已经面对了使用react的Invariant violation: rendered fewer hooks than expected问题。从其他答案来看,显然不应该有条件地调用钩子()。我决定安装eslint-plugin-react-hooks以防止将来出现类似的情况。现在它用React Hook "useState" is called conditionally.React Hooks must be
IMO,React是一种非常适合于从道具中选择使用值或使用自己状态的模式,但是当我有条件地使用钩子时,棉线出现了一些错误。我试着使用钩子,条件如下,但使用的是eslint错误React hook useState is called conditionally。根据这个,React relies on the order in which Hooks are ca