I
I
Idobrodushniy2017-08-14 21:39:45
JavaScript
Idobrodushniy, 2017-08-14 21:39:45

How to control the state of a component in a table(container) in React-Redux?

I have a container, for example:
9390b4916fc5457a93731b5328921c7a.png
The question is this: Each Component that I render in a loop in the container is a table row that, when clicked, works like a BS3 accordion. So, how to track clicks on each of the elements in the table through the store so that it opens? Code examples would be welcome, thanks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kulaeff, 2017-08-14
@kulaeff

If I understand the question correctly, then something like this:

handleComponentClick = (id) => {
  // тут можно дернуть экшн, чтобы открыть строку таблицы
}
...
this.jquerylist.map(el => {
  <Component key={el.id} onClick={() => this.handleComponentClick(el.id)}/>
})

You can do the same, but not by ID, but by index.
Why are you making an ajax request in componentWillMount? After all, you can pull an action that will make a request and save the result in the store.
Why are you making an ajax request with jQuery? Are you only using jQuery for ajax requests? To do this, there is fetch (native + there is a polyfill) or axios.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question