简体   繁体   中英

Stateful and stateless react component

What is it like to render stateful components inside stateless component? Does it affect the use case of stateless component?

Each component goes through its own lifecycle and is independent regardless of whether they are rendered within a stateful or a stateless component. Also a stateful component within a stateless component doesn't affect the parent component.

The only caveat to this is that is a component higher up in the hierarchy stops render by implementing shouldComponentUpdate or extending PureComponent (doesn't re-render when no change in props or state) or by using React.memo for functional components. The children lifecycle methods or updates will also not be triggeres.

No, It doesn't.

The life-cycle methods that are associated with a component that has state should work independently of where they are in the component hierarchy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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