redux-actions

redux-logger not showing action names suddenly only “object, object”

寵の児 提交于 2020-12-15 05:41:29
问题 I learn react and try to get Redux to work so I use the Redux-logger. When dispatching two actions from App.js it works as the top image show "ALBUME_DATA_LOADED". Then I make a dispatch from from another place and get this output: I'm not sure I sent that "object, object" action I place breakpoint and console log and it's strange the react-logger it catching an action that I dont think I sent.. Any idea? Here is the action types I use in the below code as userActionTypes : File user.types.js

first time getting undefined props from mapStateToProps

被刻印的时光 ゝ 提交于 2020-02-06 07:24:05
问题 how can i get asynchronous reducers data ,i search but didn't get solution Booking component cutPick = () => { this.props.pickup(false); } action creator export function pickup(latlng) { return function (dispatch) { dispatch({type:PICKUP_STATE,payload:latlng}); } } reducer import {PICKUP_STATE} from '../actions/types'; export default function (state={},action) { switch(action.type) { case PICKUP_STATE: return {...state,pickup:action.payload} } return state; } Map component import React from

React redux-actions

倾然丶 夕夏残阳落幕 提交于 2020-01-19 02:02:53
// npm install --save redux-actions 1:作用: 当我们的在开发大型应用的时候,对于大量的action,我们的reducer需要些大量的swich来对action.type进行判断。 redux-actions可以简化这一烦琐的过程,它可以是actionCreator,也可以用来生成reducer, 其作用都是用来简化action、reducer。 主要函数有createAction、createActions、handleAction、handleActions、combineActions。 createAction 原来创建: export const getCeshi = options = > { return { type: [ MINE ] , payload: request ( services.data ) , } } 现在: import { createActions } from 'redux-actions' import { MINE, MINE2 } from '@/constants' export const getMine = createActions ( { [ MINE ] : options = > options, [ MINE2 ] : options = > options, // [ MINE

What does this array-style destructuring on a function do in ES6?

独自空忆成欢 提交于 2019-12-08 00:55:29
问题 I read through the redux-actions tutorial, and am confused by their use of (what I believe to be) destructuring. Below is an example ( increment & decrement are both functions returned by the createAction function). const { createAction, handleActions } = window.ReduxActions; const reducer = handleActions( { [increment]: state => ({ ...state, counter: state.counter + 1 }), [decrement]: state => ({ ...state, counter: state.counter - 1 }) }, defaultState ); Here's another example of this being

appstore-react v2.0—redux-actions和redux-saga的应用

放肆的年华 提交于 2019-11-30 06:37:00
开发文档 https://redux-saga.js.org/ https://redux-saga-in-chinese.js.org/ https://redux-actions.js.org/ 源码 代码已经上传到github中,欢迎star或者fork appstore-react-v2.0 redux-saga 一、介绍 之前异步处理用的是redux-thunk + redux-actions + redux-promise,但是随着ES6中Generator的出现,人们发现用Generator处理异步可以更简单。而redux-saga就是用Generator来处理异步。 redux-saga文档并没有说自己是处理异步的工具,而是说用来处理边际效应(side effects),这里的边际效应你可以理解为程序对外部的操作,比如请求后端,比如操作文件。 redux-saga同样是一个redux中间件,它的定位就是通过集中控制action,起到一个类似于MVC中控制器的效果。 同时它的语法使得复杂异步操作不会像promise那样出现很多then的情况,更容易进行各类测试。 二、 安装 npm install --save redux-saga 三、saga常用辅助函数 put、call、takeEvery、takeLatest 1、put和call