真的不可以在 React 组件内部嵌套定义子组件吗? - PRIN BLOG #17
Replies: 3 comments 9 replies
-
非常有意义的文章,其实最重要的还是要老老实实把 ESLint 开好,能避免太多这样的低级错误了😭 |
Beta Was this translation helpful? Give feedback.
0 replies
-
其实react/no-unstable-nested-components的eslint规则规避不了这个问题https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md |
Beta Was this translation helpful? Give feedback.
3 replies
-
不是很理解为什么依赖数组会导致缓存失效,应该只有在依赖数组中的内容出现变化的时候,这个组件才会被重新渲染,而且在这种情况下也确实需要重新渲染,即使是把它拆成外部组件,props变了同样会重新渲染啊。。。 |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
真的不可以在 React 组件内部嵌套定义子组件吗? - PRIN BLOG
最近在 Code Review 时,看到有同事写了这样的代码: function TodoList() { const [list, setList] = useState([]); const TodoItem = useCallback((props) => { return
https://prinsss.github.io/react-unstable-nested-components/
Beta Was this translation helpful? Give feedback.
All reactions