I pass values through redux
scenario is when I click on the navigation bar of component 1 and refresh the ajax of component 2
is the data returned by ajax accepted by this.state.contnet
what should I write? There is an urgent need for ideas.
I pass values through redux
scenario is when I click on the navigation bar of component 1 and refresh the ajax of component 2
is the data returned by ajax accepted by this.state.contnet
what should I write? There is an urgent need for ideas.
then you should distribute an action that is responsible for requesting data
when you click on component 1, handleclick
this.props.dispatch({type:'COMPONENT2_AJAX'})
then after the COMPONENT2_AJAX action in actions is successful, that is, after getting the data, execute
dispatch ({type:'SET_STATE_CONTENT',content})
modify content,. I don't understand why you use redux and state
with redux, you have to hand over all state
to redux management, and this.state
is only used within the component. Between components, you need to pass state
managed by redux through props
.
you are in the event of clicking component 1
you call the ajax method of component 2 in the click component 1 method, and setState the result into content
1.rootSaga.js import { fork, all } from "redux-saga effects"; import sub-sagas from submodules import { assemblyLineSaga } from "@ routes Devops AssemblyLine saga"; import { DashboardSaga } from "@ routes Devops Dashboard sa...
The loading effect is handled uniformly in dva, but loading cannot be cancelled when an error occurs in the request. What should I do? ...
update the store data twice in a row, and the second time you will get the original store such as . initState ={ a: , b: }; dispatch(setState(a,1)) dispatch(setState(b,1)) the final state result is { a: , b:1 } if you repla...
realize the function of adding and subtracting numbers by clicking buttons through redux. it doesn t work according to other demo. I don t know what the problem is. Please explain paste the code below. ...
I want to write that the value of state is retrieved from the background when reducer, is initialized. How should it be implemented? whether to use redux-thunk directly dispatch a function operation interface or state? that dispat already exists when u...
as mentioned, I have a project with multiple components, all of which have some event handling and operations. And different action events within these components may result in the same result, including updates to the redux. for example, I have two m...
redux-thunk const fetchData = (params) => (dispatch) => { setTimeout(() => { dispatch({action: GET_DATA , payload: 111}) }) } dispatch const fetchData = (params) => ({action: GET_DATA , payload: 111}); setTimeout(() =>...
as the title if only component A will request apiA to get data, and the data will only be used by that component, then whether the data should be put into redux? unrelated questions: if the request does not depend on the view content, should the req...
how does it mean that return {} is an object, and then a comma separates two? Don t understand the meaning of the book ...
I just started to learn js,react, and redux, is doing exercises by myself, but I want to transfer the data of store to the state, of react, but it is not successful. Please give me some guidance. what you want to do: transfer the data obtained by API...
there is a problem with using mobx: obtain the backend interface data through @ action, then assign a value to @ observable data, and then calculate whether the modal needs to be displayed from data through @ computed modalVisiable. How can I change t...
The list is an interface, and then get the specific details according to the id of the list, and then splice the information of the list in redux state. However, if the then after the list request calls the API of details, there is no guarantee that the ...
when the mapDispatchToProps method is passed into the connect, the dispatch in the component is undefined; when the mapDispatchToProps method is not passed into the connect, the dispatch in the component can be obtained Why does this happen? ...
import React from react ; import ReactDOM from react-dom ; import {HashRouter as Router, Route, Switch} from react-router-dom import {createStore, applyMiddleware, compose} from redux import thunk from react-thunk import {Prov...
look at the title, I guess you don t understand, ha, I don t understand either? Let me describe it in detail this is the case. I intend to store a data in redux. This data will be used in some sub-component of the application. The default value ne...
namespaceperformanceconsoleperformance: each field output of the first console is empty, the second console will return the data of the first dispatch request, and the third time will return the data of two dispatch, but the network of the console on...
how to store redux information without losing related information after page refresh, do localstorage or cookie local storage? If you are doing local storage, how do you get the relevant redux information after entering the page for the first time? Is th...
the An and B codes of both models are the same, as follows: export default { namespace: A B , state: {} effects: { *add({payload}, {call, put}){ console.log("") yield put({ type: add , ...
the specific scenarios are as follows: reducer.js const initialState = { test: [ { id: 1 show: true }, { id: 2 show: true }, { ...
has been plagued by a problem, that is, the value saved by this redux, . for example, a data structure is obtained through api, but before the fetch comes down, the page will be rendered once. At this time, the data structure does not exist in redux, s...