react-redux

__WEBPACK_IMPORTED_MODULE_4_react___default.a.memo is not a function

半世苍凉 提交于 2020-01-13 08:37:04
问题 I just connect the app with redux and react-redux connect function, together with state and dispatches. It compiled without problems but the results are not showing. And it looks like below. I tried to find it and found that i have to change react version. $ sudo npm install --save react@16.4.0 react-dom@16.4.0 But it didn't work. I am following this tutorial. https://www.youtube.com/watch?v=BxzO2M7QcZw 回答1: This is also happen to me. What I figure it out is that this is happen because of

React Datepicker with redux-form

我们两清 提交于 2020-01-13 07:15:34
问题 How to make the react-datepicker bind with redux-form? I have this redux-form field: <Field name="due_date" component={props => <DatePicker {...props} readOnly={true} selected={this.state.due_date} value={this.state.due_date} onChange={this.handleDueDate} /> } /> Whenever i submit the redux form does return an empty object not binding the datepicker's value... my onChange : handleDueDate(date) { this.setState({ due_date: moment(date).format('L') }, () => { // do I need to dispatch and action

How to show loading UI when calling getComponent in react-router?

时光怂恿深爱的人放手 提交于 2020-01-12 20:33:09
问题 I'm really new to React and I can't figure out how to render a "loading..." screen when a route is being loaded with getComponent. The getComponent call works fine and displays the component, but there's no indication on the UI that anything is happening between the request and the response. That's what I'm trying to figure out. import Main from './pages/Main.jsx'; import Test from './pages/Test.jsx'; import Home from './pages/Home.jsx'; var Routes = { path: "/", component: Main, indexRoute:

Access prop outside of class in React when calling Higher Order Component

这一生的挚爱 提交于 2020-01-12 19:28:27
问题 I am trying to use a Higher Order Component(HOC) pattern to reuse some code that connects to state and uses the Redux Form formValueSelector method. formValueSelector requires a sting referencing the name of the form. I would like to set this dynamically and be able to use this HOC whenever I need the values of items. I use the item values to make calculations. In the code below the HOC is passed the component and a string. I would like to set this to the prop formName that has been passed in

Access prop outside of class in React when calling Higher Order Component

China☆狼群 提交于 2020-01-12 19:28:25
问题 I am trying to use a Higher Order Component(HOC) pattern to reuse some code that connects to state and uses the Redux Form formValueSelector method. formValueSelector requires a sting referencing the name of the form. I would like to set this dynamically and be able to use this HOC whenever I need the values of items. I use the item values to make calculations. In the code below the HOC is passed the component and a string. I would like to set this to the prop formName that has been passed in

Why am I getting this warning `No duplicate props allowed react/jsx-no-duplicate-props`

家住魔仙堡 提交于 2020-01-12 04:47:06
问题 Why am I getting this warning? warning No duplicate props allowed react/jsx-no-duplicate-props# It's showing line number 28 but there is nothing props is using. 回答1: You probably passed the same prop twice to a Component. e.g. <MyComponent someProp={'a'} someProp={'b'} /> 回答2: I also go this error, I was rendering a component and passed 'className' twice. My solution was found here with How to apply multiple classnames to an element. I then just concated the names together, the error went

Load data before createStore

↘锁芯ラ 提交于 2020-01-11 12:08:30
问题 I’ve created some React files where one initializes a Redux store. However, I really need to load some data from a json file before store is initialized. I’ve tried to import a script loading the json structure then assigning it to the createStore initialState value. But createStore runs before the data is loaded and assigned. Is there any simple way to say “dont do anything before my axios call is done”??? 回答1: Action types actiontypes.js export const LOAD_DATA_REQUEST='LOAD_DATA_REQUEST';

Do I always need to return a value from a redux middleware?

僤鯓⒐⒋嵵緔 提交于 2020-01-11 00:57:08
问题 In the examples given in the redux docs, there always seems to be something being returned from middlewares. However, when I call next(action) and return nothing everything seems to work fine. In the redux source it appears to be calling dispatch on the returned value of every middleware. This leads me to believe that it provides an optional way to run dispatch after all the middlewares have run. Can someone confirm if we must ALWAYS return a value from a middleware, and if so why? 回答1: I

Why do we need to export the connect method for it to work?

岁酱吖の 提交于 2020-01-10 03:17:05
问题 If i try to connect a component without exporting directly it fails to connect. Example: connect(mapstatetoprops, mapdispatchtoprops)(Componentx); export default Componentx; Why should this make any difference? 回答1: connect doesn't do anything to the original component, rather it is the implementation of the High Order Component pattern: so it that takes a React component as an argument and returns another component by the performing the actions it need to do like providing the action

Editable Form ReactJS

旧街凉风 提交于 2020-01-09 08:16:06
问题 import React, { Component } from 'react'; let _ = require('lodash'); import {bindActionCreators} from "redux"; import {connect} from 'react-redux'; import {fetchedBeaconsEdit} from '../../actions/'; import {editBeacon} from '../../actions/index'; // TODO - come up with a decent name class InfoRow extends Component { render() { return ( <tr> <td> { this.props.beacon === "name" || this.props.beacon === "major" || this.props.beacon === "minor" || this.props.beacon === "beaconType" ? <span>{this