I'm mainly using Vue, and just recently picked up React. Loving it so far, and its quite similar in a lot of ways to Vue, which makes learning it way easier.
Now, let's consider two siblings component. I want to trigger something in component number one, when something happens in component number two. In Vue you can just bind window.bus = new Vue
, and then emit in one of the components bus.$emit('event')
and bind in the mounted()
of the second component bus.$on('event', this.doSth)
.
How can you achieve that in React?