我要从套接字服务获取数据,而不是要通过redux保留数据。
无需更改组件,只需获取数据并实时写入即可。
但是我做不到,我怎么做?请帮助我。
Index.js
// React
import React from 'react';
import ReactDOM from 'react-dom';
import * as serviceWorker from './serviceWorker';
// Redux *********************************
import { Provider } from 'react-redux';
import { store } from './Redux/store';
Redux Store.js
import { createStore } from 'redux';
import { rootReducer } from './rootReducer';
export const store = createStore(
rootReducer
);
rootDeducer.js
import { combineReducers } from 'redux';
import { someReducer } from './reducers/someReducer';
const allReducers = {
someReducer
};
export const rootReducer = combineReducers(allReducers);
someReducer.js
const initialState = {
someValue: 12
};
export const someReducer= function(state = initialState, action) {
switch (action.type) {
case 'CHANGE':
const someVlue= Object.assign({}, state, { someValue:
action.payload.someVlue});
return someValue;
default:
return state;
}
};
答案 0 :(得分:0)
例如,您可以通过websocket调度每次更新的操作。
setMaxScrap(int viewType, int max)