redux

React Native - “You are currently using minified code outside of NODE_ENV === ”production“ ”

淺唱寂寞╮ 提交于 2020-01-03 21:54:57
问题 I'm getting this error with React Native, not ReactJS so all the solutions/workarounds with webpack or browserify wont help. Full error: You are currently using minified code outside of NODE_ENV=== "production". This means that you are running a slower development build of Redux. You can use ... bla bla bla ( workarounds for ReactJS ) I'm currently running this config : "expo": "^23.0.0", "react": "16.0.0", "react-native": "https://github.com/expo/react-native/archive/sdk-23.0.0.tar.gz",

redux dispatch fires multiple times

守給你的承諾、 提交于 2020-01-03 18:38:27
问题 I'm experiencing following unwanted behaviour in Redux (React/ Redux + redux-thunk): I'm triggering an event (click) wich lets an action fire and dispatch some additional data as objects in an array. When I'm clicking the first time the action dispatches once with one object in the array (result 1: one new object) - and that's fine. But now the unwanted thing happens: When I'm clicking the second time calling for new additional data the action dispatches twice - first time with the formerly

redux dispatch fires multiple times

只谈情不闲聊 提交于 2020-01-03 18:37:06
问题 I'm experiencing following unwanted behaviour in Redux (React/ Redux + redux-thunk): I'm triggering an event (click) wich lets an action fire and dispatch some additional data as objects in an array. When I'm clicking the first time the action dispatches once with one object in the array (result 1: one new object) - and that's fine. But now the unwanted thing happens: When I'm clicking the second time calling for new additional data the action dispatches twice - first time with the formerly

How do I create a leading debounce with redux-saga

廉价感情. 提交于 2020-01-03 15:54:34
问题 Is there a way to do a leading debounce? The example on the recipes only shows a trailing debounce. So below is trailing debounce example where we delay the logic fro 500ms: import { call, cancel, fork, take, delay } from 'redux-saga/effects' function* handleInput(input) { // debounce by 500ms yield delay(500) ... } function* watchInput() { let task while (true) { const { input } = yield take('INPUT_CHANGED') if (task) { yield cancel(task) } task = yield fork(handleInput, input) } } where as

How do I create a leading debounce with redux-saga

自古美人都是妖i 提交于 2020-01-03 15:52:10
问题 Is there a way to do a leading debounce? The example on the recipes only shows a trailing debounce. So below is trailing debounce example where we delay the logic fro 500ms: import { call, cancel, fork, take, delay } from 'redux-saga/effects' function* handleInput(input) { // debounce by 500ms yield delay(500) ... } function* watchInput() { let task while (true) { const { input } = yield take('INPUT_CHANGED') if (task) { yield cancel(task) } task = yield fork(handleInput, input) } } where as

How do I create a leading debounce with redux-saga

陌路散爱 提交于 2020-01-03 15:52:07
问题 Is there a way to do a leading debounce? The example on the recipes only shows a trailing debounce. So below is trailing debounce example where we delay the logic fro 500ms: import { call, cancel, fork, take, delay } from 'redux-saga/effects' function* handleInput(input) { // debounce by 500ms yield delay(500) ... } function* watchInput() { let task while (true) { const { input } = yield take('INPUT_CHANGED') if (task) { yield cancel(task) } task = yield fork(handleInput, input) } } where as

React/Redux + super agent, first call gets terminated

无人久伴 提交于 2020-01-03 09:20:09
问题 I am writing a react-redux app where I am making some service calls in my middlewares using superagent. I have found a very strange behavior where the first call to my search api always gets terminated. I have tried waiting 10-30 seconds before making the first call, and logging every step along the process and I cannot seem to pinpoint why this is happening. My action creator looks like export function getSearchResults(searchQuery) { return { query: searchQuery, type: actions.GO_TO_SEARCH

Reselect - does it ever make sense to create a memorized selector which is just used to get part of the state?

别说谁变了你拦得住时间么 提交于 2020-01-03 08:31:34
问题 I have a normal selector which is just used to get part of the state: export const getAllPosts = state => { return state.posts; }; If I use the reselect to wrap the selector: import { createSelector } from 'reselect'; export const allPosts = createSelector( getAllPosts, (posts) => posts ); Does it make any sense such as improving performance ? In my opinion, the wrapper is unnecessary. 回答1: No, it does not make sense to create a memoized selector just to get part of the state tree. The reason

Failed to parse “4.” to 4

青春壹個敷衍的年華 提交于 2020-01-03 02:50:06
问题 I am working in React-redux and creating a number type field. The event.target.value returns a string, since it is number type editor it must return value as number so I parse the value to number. The problem comes when I try to enter 4.5 . Firstly, when I type 4 it will get parsed into 4 (sting to number). But when the . entered the number 4. get parse into 4 , so I just failed to enter the floating point values. let onChangeText = (value)=> { fieldProps.onChange(parseFloat(value)); } If I

React: Dispatch not firing on route change

眉间皱痕 提交于 2020-01-03 02:31:28
问题 I have several routes that use the same controller: <Route component={Search} path='/accommodation(/:state)(/:region)(/:area)' /> and when the route is changed I call the api function from within the component: componentWillReceiveProps = (nextProps) => { if (this.props.params != nextProps.params) { loadSearch(nextProps.params); } } which is an action as follows: export function loadSearch (params) { return (dispatch) => { return dispatch( loadDestination(params) ).then(() => { return