Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React组件有哪些通信方式? #942

Open
pwstrick opened this issue Apr 17, 2020 · 1 comment
Open

React组件有哪些通信方式? #942

pwstrick opened this issue Apr 17, 2020 · 1 comment
Labels
React React类的题目

Comments

@pwstrick
Copy link
Owner

React组件有哪些通信方式?

@pwstrick pwstrick added the React React类的题目 label Apr 17, 2020
@pwstrick
Copy link
Owner Author

1、父子通信,父组件通过props向子组件传递需要的信息。
2、兄弟通信,兄弟之间不能直接通信,需要借助状态提升的方式间接实现信息的传递,即把组件之间要共享的状态提升至最近的父组件中,由父组件来统一管理。
3、跨级通信,可用Context实现跨级通信。
4、无级通信,当两个没有嵌套关系(即无级)的组件需要通信时,可以借助消息队列实现。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
React React类的题目
Projects
None yet
Development

No branches or pull requests

1 participant