redux

Why Curry Redux Middleware: state => next => action {} vs. (state, next) => action {}

北战南征 提交于 2020-01-05 11:48:10
问题 After reading both Redux's documentation on middleware and source code on applyMiddleware, I don't understand why middleware need the curry syntax: const logger = store => next => action => { console.log('dispatching', action) let result = next(action) console.log('next state', store.getState()) return result } Couldn't the same thing be achieved by doing const logger = (store, next) => action => { console.log('dispatching', action) let result = next(action) console.log('next state', store

Firebase - Losing Auth Session After An Hour

我与影子孤独终老i 提交于 2020-01-05 09:04:50
问题 I added Firebase auth to my Reactjs (and Redux) web app and everything works perfectly. I'm using email / password sign in, and call firebase.auth().signInWithEmailAndPassword which persists on reloads, tab changes, etc. However, after about an hour, the auth session appears to expire and currentUser is set to null. It feels like there should be a setting somewhere in the Firebase console, but after searching through it, I can't find anything. Any help would be really appreciated! 来源: https:/

How to handle async function in redux-observable?

。_饼干妹妹 提交于 2020-01-05 09:04:37
问题 I am using RxJS and redux-observable. I am trying to read file in epic. In my case, I have to do it in epic, because some other epic trigger this epic multiple "unknown" times by expand operator. But since FileReader is async, the code below does not work. What is the correct way especially RxJS way to handle this? Thanks export const uploadAttachmentEpic = (action$, store) => action$ .ofType(UPLOAD_ATTACHMENT) .map(action => { const reader = new FileReader(); reader.onload = () => { return {

which way is better?

血红的双手。 提交于 2020-01-05 08:32:38
问题 I am developing an E-Commerce website using React, Redux, the website shows some products, these products can be sorted or filtered by a selectbox with some options. I have two options for filtering products: 1 - fetching products everytime from the server and doing a check in the fetch function for example: products = products.filter(p => options.find(o => p.categories.find(category=> category=== o)) ); 2 - fetching products once then creating a reducer that filters products every time

which way is better?

牧云@^-^@ 提交于 2020-01-05 08:32:13
问题 I am developing an E-Commerce website using React, Redux, the website shows some products, these products can be sorted or filtered by a selectbox with some options. I have two options for filtering products: 1 - fetching products everytime from the server and doing a check in the fetch function for example: products = products.filter(p => options.find(o => p.categories.find(category=> category=== o)) ); 2 - fetching products once then creating a reducer that filters products every time

React componentDidUpdate not receiving latest props

血红的双手。 提交于 2020-01-05 08:16:27
问题 In Redux, I'm running the following in a redux-thunk action creator: dispatch({type: "CASCADING_PROMPT_STATUS", promptName, list: 'model', status: 'disabled'}); dispatch({type: "CASCADING_PROMPT_STATUS", promptName, list: 'model', status: 'enabled'}); This triggers the reducer twice, and I can see in the console that Redux state changes from disabled -> enabled. In React, I have the following component which has props connected to state of which CASCADING_PROMPT_STATUS updates. However, in my

How does middleware execute async actions?

 ̄綄美尐妖づ 提交于 2020-01-05 07:12:43
问题 I am having a little difficulty understanding how Redux-Thunk (or other middleware) execute async actions. From below example, I can see that when onOrder is called (maybe via a click event), it will dispatch the action created by purchaseBurger . purchaseBurger in turn return a function that will dispatch an action indicating purchase started, followed by an http request. My confusion is: When does that function returned by purchaseBurger actually gets called and executed? How does it get

npm install classnames not working in my li tag

烈酒焚心 提交于 2020-01-05 05:58:47
问题 I am new to React JS. I am trying to combine my classes using npm package classnames. https://www.npmjs.com/package/classnames but it's not working: classname is not executing first-time-active ... am I using it correctly? When I use normally the class is working. can you guys tell me what's the problem? It's in this line: <li role='presentation' key={index} className={`${liClassName} ${className}`}> providing code below: import CombineClassName from 'classnames'; let

react router version 4 not showing anything

大城市里の小女人 提交于 2020-01-05 05:58:30
问题 I think that I am doing something wrong with my React router. I am a beginner to React/Redux so any help is really appreciated. It could also be how I configured webpack, but my front end is showing nothing, but I am not getting any errors at all. I'm not sure what the problem is, but my server starts, is able to populate mock data, and webpack compiles, so I think the backend works. I'm so sorry for the wall of code but I really have no idea where I'm going wrong and I am a huge newbie to

How to back from Component in react redux

六眼飞鱼酱① 提交于 2020-01-05 05:45:11
问题 i have a Car page, includes one edit and add components, it's working fine when i dispatch with button now i am trying to back from the component using button, i tried history.goBack but its going to home page Home page localhost:8080/ Issue page localhost:8080/car/5c7a29418c57f7069f382491 above page, i have <CarAdd> and <CarEdit> includes, dispatch using below button <button type="button" onClick={() => this.props.dispatch({ type: 'ADD_NEW_CAR'})}> Add Car </button> then Add car shows, i