redux

Redux dispatch causing component local state to reset

狂风中的少年 提交于 2020-01-03 02:08:47
问题 I'm using Redux with React. I'm using this.state (component local state) to save component specific variables. Problem is that my components state resets to initial state whenever I dispatch an action (fetch action) and Store updates (mounts). Is this the correct behavior for my component? Should the component's state reset when it mounts a second time (re-render)? If (1) is true, is there a way to preserve certain variable values in this.state when it receives new props from Redux store? I

How do I change the layout for smaller screens in material ui?

烂漫一生 提交于 2020-01-03 01:42:36
问题 I am new to responsive material design. when I move to smaller screens, Sports Status should stay in the right corner. and 4Standard, 5Standard, 6Standard, 7Standard, 8Standard, 9Standard should come to next line. i googled and found the below line for media queries and tested color is changing, but not sure how to change the layout ["@media (min-width:780px)"]: { // eslint-disable-line no-useless-computed-key backgroundColor: "red" } is it possible to change the structure of my layout using

redux-simple-router - perform action based on URL

♀尐吖头ヾ 提交于 2020-01-02 07:05:21
问题 I'm using Redux with redux-simple-router. Here's what I'm trying to do. A user hits a URL like so: http://localhost:3000/#/profile/kSzHKGX Where kSzHKGX is the ID of the profile. This should route to Profile container filled out with the details of the profile with id kSzHKGX . My routes look like this: export default ( <Route path="/" component={App}> ... <Route path="profile" component={Profile} /> ... </Route> ) So hitting the above link would give me Warning: [react-router] Location

redux-simple-router - perform action based on URL

99封情书 提交于 2020-01-02 07:04:06
问题 I'm using Redux with redux-simple-router. Here's what I'm trying to do. A user hits a URL like so: http://localhost:3000/#/profile/kSzHKGX Where kSzHKGX is the ID of the profile. This should route to Profile container filled out with the details of the profile with id kSzHKGX . My routes look like this: export default ( <Route path="/" component={App}> ... <Route path="profile" component={Profile} /> ... </Route> ) So hitting the above link would give me Warning: [react-router] Location

Why does Redux Promise return unresolved promise if more than type and payload options are specified?

我的未来我决定 提交于 2020-01-02 04:56:29
问题 I'm having tough time figuring out why this is happening, but essentially Redux Promise was working fine for me while returning something like: return { type: STORY_ACTIONS.STORY_SPOTIFY_REQUEST, payload: request } However, I now need to pass another information with it like so return { order: 0, // New field type: STORY_ACTIONS.STORY_SPOTIFY_REQUEST, payload: request } This results in an unresolved promise instead of data. I tried renaming order to something like position or index ... still

Ngxs - Call an Angular service : good practices?

二次信任 提交于 2020-01-02 04:35:12
问题 When I use ngxs what should my app do: my component calls a service and the service dispatches an action with the result as the payload? my component dispatches an action and my State calls the service? 回答1: You can do both and if you look into open source apps you'll probably find both. So far I've personally (with ngrx but it's the same) injected the store and dispatched actions from the (smart) components. But I've been reading a lot of articles about facades lately and I think it's

Angular2 + ngrx/store for handling failure HTTP requests

℡╲_俬逩灬. 提交于 2020-01-02 02:23:07
问题 I want to have a simple code path for creating and dispatching HTTP actions. What I would like to do is something like: this.http.request(...) .map((res: Response) => res.json()) .catch((err: any) => err.json()) .map((payload: any) => { type: 'SUCCESS', payload }) .catch((payload: any) => { type: 'FAILURE', payload}) .subscribe((action: Action) => this.store.dispatch(action)); That way both the success and failure responses are converted to JSON and then based upon the success/fail criteria

Progress bar with redux

一笑奈何 提交于 2020-01-02 00:50:31
问题 I have a background upload process in my react/redux application that updates very frequently. My reducer looks something like this: export default function progressReducer(state = initialState, action = {}) { switch (action.type) { case PROGRESS_TOTAL_INCREASE: return Object.assign({}, state, {total: state.total + action.amount}); case PROGRESS_CURRENT_INCREASE: let current = state.current + action.amount, total = state.total; if (current >= state.total && false) { state.total = 0; current =

Is it possible to connect non component Class to redux store?

拟墨画扇 提交于 2020-01-02 00:49:28
问题 So I am using a react-redux boilerplate that has an ApiClient helper. It looks like this: export default class ApiClient { constructor(req) { /* eslint-disable no-return-assign */ methods.forEach((method) => this[method] = (path, withCredentials, { params, data } = {}) => new Promise((resolve, reject) => { const request = superagent[method](formatUrl(path)) if (withCredentials) { console.log('first of all, its true') console.log(this) } if (params) { request.query(params) } if (__SERVER__ &&

React/Redux store state is not saved

≯℡__Kan透↙ 提交于 2020-01-01 15:57:33
问题 I use thunk middleware and pass initial state to React, but the problem is that React state is not saved when I visit other links. After successfully logged in, it's supposed to render dashboard. User must be redirected to dashboard(which is the root path, / ) when he tries to go to /login page. Should i use redux-router too? I omitted some of code, but it almost looks like below. init.js I passed store to Provider import { Provider } from 'react-redux'; import configureStore from './store