current position:Home>React realizes the communication of brother components by means of message subscription and publication

React realizes the communication of brother components by means of message subscription and publication

2022-04-29 06:10:45Everything wins sy

1. install pubsub-js

yarn add pubsub-js

Use
 Insert picture description here
Unsubscribe
 Insert picture description here

practice

1. Subscribe to news

As long as someone publishes a message with the same name, they can receive it
 Insert picture description here
2. Release the news

 Insert picture description here

details :https://github.com/mroderick/PubSubJS

copyright notice
author[Everything wins sy],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/116/202204261001226949.html

Random recommended