简体   繁体   English

将页面拆分为不同的React组件

[英]Splitting the page into different React components

I am new to Reactjs. 我是Reactjs的新手。 I am super duper confused when it comes to splitting the page to different components. 在将页面拆分为不同的组件时,我非常困惑。 What should I consider when I divid the page into different components? 将页面分为不同部分时应该考虑什么?

When you want to split into separate components, it becomes a bit of a challenge to share data between them. 当您想要拆分为单独的组件时,在它们之间共享数据将成为一个挑战。 One way is for the parent to share state through props and actions to the children, but this ends up being messy, and your components depend pretty much on each other. 一种方法是让父母通过对孩子的道具和动作来分享状态,但这最终会很混乱,并且您的组件之间非常依赖。

Most people do it using Redux, although you can do it with Observables or mobX. 尽管您可以使用Observables或mobX进行操作,但大多数人都使用Redux进行操作。

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

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