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.
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.
you can't see anything wrong with the code you posted.
you should follow the official example, step by step.
We generally treat state as a tree rather than a number.
are you not doing status monitoring? Subscribe is used to subscribe to changes in store. For example, every time you dispatch (action) store, it triggers the function call registered by subscribe
.store.subscribe ()
The details of are not very clear, but store.getState ()
should be used in the callback of store.subscribe ()
, so that you can see the changes. In addition, it is recommended that you read it according to official Chinese document , because redux can be directly used on React (after all, it has nothing to do with the framework). However, it is recommended that react's state be managed by redux through react-redux.
Previous: How does javascript find all prime factors of a number?
Next: How to obtain and store data after vue Wechat scanned the code and logged in
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. ...
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...
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...