redux

Where did I make the mistake of changing my search filter? And how to fix it?

跟風遠走 提交于 2019-12-13 09:04:27
问题 I have a list of airplanes departing or arriving at the airport and i also had a search filter where i enter the time of arrival or departure and filtering of the airplanes. I do this using the actual property of my API. But I needed to change my search. Now I need to search by flight number - the planeTypeID.code property of my API. But when I changed it, stopped showing a list of airplanes. What is my mistake and how to fix it? I just instead actual everywhere wrote ["planeTypeID.code"] and

Clean way to re-route user that isn't logged in with React?

故事扮演 提交于 2019-12-13 08:39:26
问题 I guess I could always add login in WillTransitionTo which would do a call to the store via Redux to verify that the user is logged in but this seems a bit hacky, especially since since I have to add WillTransitionTo() logic to every single component. Anyone have any better ideas? I'm going to work toward wiring something into isAuthorized with the onEnter . This is the root root of the application which performs the react-router wire-up. react-router : 2.0.4 react: 15.0.2 const store =

axios get requests and displaying in table

喜夏-厌秋 提交于 2019-12-13 08:14:48
问题 I am new to react and redux, I'm using axios, I am able to fetch the data from the api, I saw it by printing it in console, but not sure how to load the data in the table. The table code is in sports/index.js and axios code is in actions/index.js I provide code and stackblitz here. export const fetchAllPosts = () => { return (dispatch) => { return axios.get(apiUrl) .then(response => { console.log("fetchAllPosts.response.data--->", response.data); dispatch(fetchPosts(response.data)) }) .catch

How to type Redux state in TypeScript to create new state without item

只愿长相守 提交于 2019-12-13 07:43:40
问题 I'm using TypeScript 2.x and Redux. I have a reducer which receives an action, based on which I wish to create a new state without some item like this: export function reducer(state = {}, action) { switch (action.type) { case SOME_ACTION: let newState : { something: string } = state; delete newState.something; return newState; default: return state; } } Thanks to @basarat I figured out the basics of deleting things ( see TypeScript 2: Remove item from 2-field object). The code above is based

What am I missing with Redux-Saga?

房东的猫 提交于 2019-12-13 07:36:25
问题 I've been trying to integrate Redux-Saga into my React/Redux app for a while now and there is some key part of this that I'm missing (as it doesn't want to work). My understanding of how this is supposed to work is as follows: In the rootSaga function, I fork off a "Watcher" which watches for a particular action to occur. When the watcher sees the action, it calls the handler for that action and calls the appropriate success/fail action when completed. I should use put or call to dispatch an

Which parts of react-virtualized package I need?

耗尽温柔 提交于 2019-12-13 07:28:37
问题 I want to make infinite scroll page with image grid. Which parts of react-virtualized package I need? InfiniteLoader and WindowScroller and Masonry ? And how define limit of records in query when I scroll window. 回答1: WindowScroller works with the Masonry component but InfiniteLoader only works with Grid and List . (The docs mention this.) And how define limit of records in query when I scroll window. This question isn't really clear. Perhaps you should try something and then post a new

How to assign new key value pair without overwriting top level keys?

久未见 提交于 2019-12-13 07:04:55
问题 How do I add a key/value pair to a nested object without overwriting the top level keys in my Redux reducer? notes state before: notes: { -KQpqwDTyLOzd-8UXi-z: { created: 1473035305252, text: 'stuff', } -KQqe4xiwV4-5WIs2Gpg: { created: 1473017044898, text: 'more stuff', } } notes state after: notes: { 0: { created: 1473035305252, text: 'stuff', new: 'new value', } 1: { created: 1473017044898, text: 'more stuff', } } here is my reducer that is producing the above results: import _ from 'lodash

Piping inside a subscribe in ngrx

喜欢而已 提交于 2019-12-13 06:29:38
问题 I have a selector that takes a parameter to filter values. The parameter depends on an observable's return. export class LineSynopticComponent implements OnInit, AfterViewInit { schedules$: Observable<ISchedule[]>; ngOninit(){ this.selectedDate$.subscribe(elm => { this.schedules$ = this.store.pipe(select(selectSchedulingsTimes, { time: elm.timeSelect })); }); } the selectSchedulingsTimes selector is defined as well: const schedulings = (state: IAppState) => state.schedulings; export const

React / Redux / Reselect - is mapped state to props using selectors synchronous or asynchronous?

回眸只為那壹抹淺笑 提交于 2019-12-13 04:25:15
问题 In our project we are using react-redux with reselect and redux-saga In the store I have a selectedStageId along with an array of stages and a memoized selector that finds and returns the correct stage based on the id. This selector is mapped to one of my components props as this.props.selectedStage , and in one of my onClick handlers, I dispatch an action to update the selectedStageId to the id of the newly selected UI item, and then attempt to pass the new selectedStage to an edit method...

Redux-Observable multiple actions in single epic

浪尽此生 提交于 2019-12-13 04:13:59
问题 I'm new to this and there are several similar questions such as redux-observable - dispatch multiple redux actions in a single epic but I can't see how they apply to my usecase. I'm using a Subject to emit multiple events based on processing a file and uploading to a server export function UploadSceneWithFile(scene){ const subject$ = new Subject() FileToScenePreview(scene,scene.file).then(res => subject$.next(res)) const uploader = new S3Upload({ .... onError:()=>subject$.next('error'),