简体   繁体   English

在 React.js 中渲染一个组件

[英]Rendering a Component in React.js

I have a Small Query, I tried to google it but couldn't find the solution.我有一个小查询,我试图用谷歌搜索但找不到解决方案。

When a React Component state is changed(useState()), so the whole page is rendered or that specific React Component is rendered like in Ajax?当 React 组件 state 被改变时(useState()),所以整个页面被渲染或者特定的 React 组件被渲染,就像 Ajax 一样?

Only the component will be rendered again.只有组件会被再次渲染。

The useState will render all the components associated with it, meaning if you put the useState in the parent component it will also re-render the children component. useState 将渲染与其关联的所有组件,这意味着如果您将 useState 放在父组件中,它也会重新渲染子组件。

When State changes in the child component do not affect the parent component, but when a parent component's state changes, all child components are rendered.当子组件的 State 变化不影响父组件,但是当父组件的 state 变化时,所有子组件都会被渲染。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM