JavaScript Passing data from distant component passing data from child to parent react,passing data from

I am wondering if there is some better way to communicate between distant components. In my case I have structure like this:

<div>
  <History />
  <Board>
    <BoxesView>
      <DataBox>
        <TagBoxItem />
      </DataBox>
    </BoxesView>
  </Board>
</div>

and I need to send some data from TagBoxItem to History (in TagBoxItem onClick action will add new item to History). And the simplest solution is to just make some callbacks and pass step by step data from TagBoxItem to main div and next pass it to History. But is this really the best way to do it ?

Answer:1

This is a valid case to explore Flux pattern. You will initiate actions through action creators in TagBoxItem, which through dispatcher will be propagated to History Store. On History Store change you will rerender History component.

Similar to Flux there is also Redux state container which gains a lot of attention at the moment. The important difference instead of multiple stores you save all the state in a single store, you will create history reducer for your case. Explore the Gist for more details.

Answer:2

as Eugene's answer, using Flux pattern is always a recommended way. If you don't want to use it, you can try create a global event system. I added the link if you are interested.

Answer:3

-- Hi ! Reader, if you are not comfortable with Tumblr, please tell me, I will give more details! I had some issues on my tumblr page with the default theme 'Optica'. When I post an embed SoundCloud ...

-- Hi ! Reader, if you are not comfortable with Tumblr, please tell me, I will give more details! I had some issues on my tumblr page with the default theme 'Optica'. When I post an embed SoundCloud ...

I would like to dynamically remove or disable a <style> tag that looks like this <style type="text/css" id="cssx/portal/simple-sidebar.css" designtr="cssx/portal/simple-sidebar.css"> #...

I would like to dynamically remove or disable a <style> tag that looks like this <style type="text/css" id="cssx/portal/simple-sidebar.css" designtr="cssx/portal/simple-sidebar.css"> #...

  1. find style attribute using jquery
  2. jquery find style attribute
  3. jquery find style attribute value
  4. javascript find style attribute
  5. find element by style attribute jquery
  6. jquery find inline style attribute

I really need help. I am a newbie programmer and really not sure how can i do this in joomla. I need to create a pop up or iframe that pass variable from the parent page. Basically what is to happen ...

I really need help. I am a newbie programmer and really not sure how can i do this in joomla. I need to create a pop up or iframe that pass variable from the parent page. Basically what is to happen ...

  1. create popup iframe javascript
  2. create iframe popup
  3. how to create iframe popup window
  4. how to create iframe popup window in asp.net

I'm trying to create a client-side only application using Firebase as a database service and I'm experiencing some difficulties defining a security rules that will allow multiple 'admin' users access ...

I'm trying to create a client-side only application using Firebase as a database service and I'm experiencing some difficulties defining a security rules that will allow multiple 'admin' users access ...