redux

React router redirect after action redux

房东的猫 提交于 2019-12-20 08:33:01
问题 I'm using react-redux and standard react-routing. I need redirect after definite action. For example: I have registration a few steps. And after action: function registerStep1Success(object) { return { type: REGISTER_STEP1_SUCCESS, status: object.status }; } I want him redirect to page with registrationStep2. How to do it? p.s. In history browser '/registrationStep2' has never been. This page appears only after successful result registrationStep1 page. 回答1: With React Router 2+, wherever you

Should I use redux-form store instead of component state and Redux custom store?

拟墨画扇 提交于 2019-12-20 08:30:07
问题 I believe in any application there should be one source of truth. My app will be having 90+ transaction forms and 150 reports Complex data structures (parent level, child level, computations) So in React I found three confusing places to store state: Component state - use when we don't want to share data Redux custom store (managed by developer) - use when we want to share data Redux-form store (managed by redux-form) - use for validation I started using redux form just for validation , and

How do you add/remove to a redux store generated with normalizr?

耗尽温柔 提交于 2019-12-20 08:25:29
问题 Looking the examples from the README: Given the "bad" structure: [{ id: 1, title: 'Some Article', author: { id: 1, name: 'Dan' } }, { id: 2, title: 'Other Article', author: { id: 1, name: 'Dan' } }] It's extremely easy to add a new object. All I have to do is something like return { ...state, myNewObject } In the reducer. Now given the structure of the "good" tree, I have no idea how I should approach it. { result: [1, 2], entities: { articles: { 1: { id: 1, title: 'Some Article', author: 1 }

React Native + Redux basic authentication

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 08:23:44
问题 I'm looking for a way to create a basic authentication for my react-native app. I couldn't find any good example for react-native app. To login, the app sends the email/password + clientSecret to my server If OK, the server returns accessToken + refreshToken The user is logged in, all other requests include the bearer with the accessToken. If the accessToken expires, the app requests a new one with the refreshToken automatically. The user stays logged in all the time, the states should be

Isn't Redux just glorified global state?

不打扰是莪最后的温柔 提交于 2019-12-20 08:23:13
问题 So I started learning React a week ago and I inevitably got to the problem of state and how components are supposed to communicate with the rest of the app. I searched around and Redux seems to be the flavor of the month. I read through all the documentation and I think it's actually a pretty revolutionary idea. Here are my thoughts on it: State is generally agreed to be pretty evil and a large source of bugs in programming. Instead of scattering it all throughout your app Redux says why not

React Native + Redux basic authentication

荒凉一梦 提交于 2019-12-20 08:22:31
问题 I'm looking for a way to create a basic authentication for my react-native app. I couldn't find any good example for react-native app. To login, the app sends the email/password + clientSecret to my server If OK, the server returns accessToken + refreshToken The user is logged in, all other requests include the bearer with the accessToken. If the accessToken expires, the app requests a new one with the refreshToken automatically. The user stays logged in all the time, the states should be

propTypes warning in Electron app

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 05:55:17
问题 I am trying to deal with the new warning about needing to include the prop-types package in NPM programs. My app is an electron app. I think I am following the migration strategy from the React folks: https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html react version-15.4.2, prop-types version 15.5.8, react-dom 15.42.2 However, I am still getting the warning after adding the prop-types package. This is the component (Dashboard.jsx) const React = require('react') const {

Failed prop type: The prop `actions` is marked as required in `Testing`, but its value is `undefined`

孤者浪人 提交于 2019-12-20 05:27:08
问题 I am creating a simple login form using React and Redux. My app.js is: import React from 'react'; import { render } from 'react-dom'; import Input from 'react-toolbox/lib/input'; import {Button, IconButton} from 'react-toolbox/lib/button'; import PropTypes from 'prop-types'; import * as loginAction from '../actions/loginAction'; class Testing extends React.Component { onLoginFormSubmit(event) { event.preventDefault(); this.props.actions.Testing(this.state.username, this.state.password); }

redirect to other page after authentication react

為{幸葍}努か 提交于 2019-12-20 04:38:46
问题 I'm building react application using react-boilerplate. I have created authentication containers using react-boilerplate generator features and combine it with this public api . It will return token after we passed email & password. How to redirect to other component / page after set the token to browser localStorage ? Thank you for your time. reducers.js import { fromJS } from 'immutable'; import { CHANGE_EMAIL,CHANGE_PASSWORD,LOGIN_REQUEST, LOGIN_SUCCESS, LOGIN_FAILURE } from './constants';

Rendering material-ui-next Checkbox inside a Redux Form

点点圈 提交于 2019-12-20 04:34:46
问题 I am having some trouble trying to render a simple material-ui-next checkbox inside a redux-form . I am following the official example and trying to adapt it to the material-ui-next equivalent, since the example is using the older version of material-ui . This is the code that I end up using: const renderCheckbox = ({ input, label }) => ( <FormGroup row> <FormControlLabel control={ <Checkbox checked={input.value ? true : false} onChange={input.onChange} value="checkedA" /> } label="Secondary"