Answer the question
In order to leave comments, you need to log in
How to organize a request for missing information in the tree in React with Baobab?
A list of several VKontakte groups is displayed. The ListItem component represents one group. Its VKontakte id is passed to the component via props. In the tree, I keep a branch under VK info:
vkdata: {
oid: { screen_name, photo_50} // ключ целое число, значение объект со свойствами
// например:
-29534144: { screen_name:'oldlentach', photo_50:'https://pp.vk.me/c624928/v624928349/3892f/cSOB14IlXgM.jpg'},
}
export default branch( ListItem, {
cursors( props, context) {
return {
vkinfo: [ 'vkdata', props.oid],
};
},
Warning: setState(...): Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.
Answer the question
In order to leave comments, you need to log in
Data control and loading should not happen in React components. You should request data using baobab-action, and it is there that you write temporary data to the tree and at the same time initiate the download from the real data server. In your example, it is just not visible that you are using baobab-action, and these are direct analogues of reducers in Redux. Here is an example of working with actions:
https ://github.com/Yomguithereal/baobab-react/blob...
Business" ( https://github.com/Yomguithereal/baobab#computed-d... But you still need to request data from the server and change it in the tree as it arrives only from ation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question