javascript - In React.js, how would I set up a simple global event system to communicate between components? -


after toying react bit, think it, there couple of things i'm struggling figure out how do. 1 of basic communication between components not in parent-child relationship.

as understand tutorial, communication done via parent-child relationship using states , props, , seems simple enough. when there no parent-child relationship, docs recommend setting global event system , leave me figure out. not sure meant this.

let's take problem i'm working on example. have <searchbar /> component in navbar of page , use populate search results in <resultstab /> component elsewhere on page. trying relate these via common parent isn't practical. how update resultstab searchbar's results? i'm sure via jquery , forget react, proper react way this?

facebook have released pattern called flux - https://github.com/facebook/flux. can verbose in simple applications, works well.

as these things, community moving very fast , making lot of changes. recommend getting used basic examples, read https://medium.com/@dan_abramov/the-evolution-of-flux-frameworks-6c16ad26bb31 , try of others.

@dan_abramov's https://github.com/gaearon/redux seems popular @ moment.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -