redux

How to make React Native mobile application faster?

不想你离开。 提交于 2019-12-20 10:34:06
问题 React Native mobile application is working very slow on every click . I am using react native v0.40.0 and following are the dependencies of my project. { "analytics-react-native": "^1.1.0", "apisauce": "^0.7.0", "babel-preset-es2015": "^6.18.0", "es6-promise": "^4.0.5", "flow-bin": "^0.36.0", "geolib": "^2.0.22", "immutable": "^3.8.1", "intl": "^1.2.5", "isomorphic-fetch": "^2.2.1", "lodash": "^4.17.4", "lodash.range": "^3.2.0", "prop-types": "^15.5.10", "raven-js": "^3.13.1", "react": "^15.4

Syntax error in IE11 with Webpack, Babel and React

↘锁芯ラ 提交于 2019-12-20 10:27:49
问题 I'm getting a Syntax Error in my React + Redux project in Internet Explorer 11, but I have no idea why it's caused. I'm using Webpack and Babel to compile it. I tried using babel-polyfill and babel-es6-polyfill, but that didn't help. This is the error I'm getting: SCRIPT1002: Syntax error File: app.js, Line: 70, Column: 1 Line 70 Column 1 is where the eval starts of Webpack: /***/ }), /* 21 */, /* 22 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nObject

Nesting a container component in a presentational component

社会主义新天地 提交于 2019-12-20 10:24:21
问题 I'm trying to refactor my app to separate presentational and container components. My container components are just the presentational components wrapped in connect() calls from react-redux, which map state and action creators to the presentational components' props. todo-list.container.js import React, {Component} from 'react'; import {connect} from 'react-redux'; import {fetchTodos} from '../actions/todo.actions'; import TodoList from '../components/todo-list.component'; export default

Jest setup “SyntaxError: Unexpected token export”

巧了我就是萌 提交于 2019-12-20 09:48:35
问题 I'm implementing tests into an existing project that currently has no tests. My tests are failing to compile node_modules/ imports. /Users/me/myproject/node_modules/lodash-es/lodash.js:10 export { default as add } from './add.js'; ^^^^^^ SyntaxError: Unexpected token export at transformAndBuildScript (node_modules/jest-runtime/build/transform.js:320:12) at Object.<anonymous> (app/reducers/kind_reducer.js:2:43) at Object.<anonymous> (app/reducers/index.js:12:47) The workaround I've found is to

Advantages of using immutable.js over Object.assign or spread operators

你离开我真会死。 提交于 2019-12-20 09:48:31
问题 So far most of "starter boilerplates" and some posts about react / redux I've seen encourage usage of immutable.js to address mutability. I personally rely on Object.assign or spread operators to handle this, hence don't really see advantage in immutable.js as it adds additional learning and shifts a bit from vanilla js techniques used for mutability. I was trying to find valid reasons for a switch, but wasn't able to hence I am asking here to see why it is so popular. 回答1: This is all about

dispatch multiple actions in one effect

ぐ巨炮叔叔 提交于 2019-12-20 09:39:10
问题 I would like to diapatch two actions in one effect. Currently I have to declare two effects to achieve this : // first effect @Effect() action1$ = this.actions$ .ofType(CoreActionTypes.MY_ACTION) .map(res => { return { type: "ACTION_ONE"} }) .catch(() => Observable.of({ type: CoreActionTypes.MY_ACTION_FAILED })); // second effect @Effect() action2$ = this.actions$ .ofType(CoreActionTypes.MY_ACTION) .map(res => { return { type: "ACTION_TWO"} }) .catch(() => Observable.of({ type:

Implementing undo / redo in Redux

浪子不回头ぞ 提交于 2019-12-20 09:37:53
问题 Background For a while now I've been wracking my brain as to how you would implement undo / redo in Redux with server interactions (via ajax). I've come up with a solution using a command pattern where actions are registered with an execute and undo method as Commands, and instead of dispatching actions you dispatch commands. The commands are then stored in a stack and raise new actions where required. My current implementation uses middleware to intercept dispatches, test for Commands and

Redux Saga async/await pattern

跟風遠走 提交于 2019-12-20 09:28:24
问题 I'm using async/await throughout my codebase. Because of this my api calls are defined by async functions async function apiFetchFoo { return await apiCall(...); } I would like to call this function from my saga code. It seems like I can not do this: // Doesn't work function* fetchFoo(action) { const results = await apiFetchFoo(); yield put({type: "FOOS_FETCHED_SUCCESSFULLY", foos: results}); } However, this does work, and matches the redux saga documentation: // Does work function* fetchFoo

How use react-redux connect with mapStateToProps,MapDispatchToProps and redux-router

安稳与你 提交于 2019-12-20 08:57:32
问题 I want to use in my container "LoginPage" (smart-component) redirect after login. Something like this: handleSubmit(username, pass, nextPath) { function redirect() { this.props.pushState(null, nextPath); } this.props.login(username, pass, redirect); //action from LoginAcitons } username and pass arrived from dumb-component. Smart component connect function mapStateToProps(state) { return { user: state.app.user }; } function mapDispatchToProps(dispatch) { return bindActionCreators(LoginActions

How to handle tree-shaped entities in Redux reducers?

两盒软妹~` 提交于 2019-12-20 08:40:07
问题 I'm a bit stuck thinking on how to implement a reducer where its entities can have children of the same type. Let's take reddit comments as an example: each comment can have child comments that can have comments themselves etc. For simplification reason, a comment is a record of type {id, pageId, value, children} , with pageId being the reddit page. How would one model the reducer around that? I was thinking of having the reducer be a map -> id of the comments where you can filter by page