react-redux

How to wait for evaluating values in React from nested requests?

[亡魂溺海] 提交于 2020-08-09 08:15:54
问题 I faced with problem that React didnt wait evalating values. I have about 10 GET requests in useEffect and then placing it on hook state: const [data,setData]=useState() useEffect(async()=>{ //here axios requests setData('here retrieved data above'); },[]); I wrapped in async function but it not helping and my react code starting without data from axios requests, but at console i see data from every request with mark "value below was evaluated just now". How I can wait for evaluating? As I

useEffect props callback function causing infinite loop

三世轮回 提交于 2020-08-06 12:43:29
问题 I have a problem very similar to this - How do I fix missing dependency in React Hook useEffect. There is one key difference - I am passing a fetch function to a child component to be called from useEffect, so I can't simply move the function into the body of the effect. The fetch function is re-created every render and causes an infinite loop. I have other local component state that I want to cause the effect to fire. I basically have a Container Component and a Presentational component.

connectedRouter Error: Could not find router reducer in state tree, it must be mounted under “router”

梦想与她 提交于 2020-08-06 07:32:25
问题 I am new to React.js and was setting up base project at that I was getting one issue that my routing got changed but component doesn't load. After googling I found that I need to use ConnectedRouter. While setting up ConnectedRouter, I am getting console error: Could not find router reducer in state tree, it must be mounted under "router" import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter } from 'react-router-dom'; import { ConnectedRouter, connectRouter,

Shouldn't Redux prevent re-rendering?

纵然是瞬间 提交于 2020-07-28 14:08:48
问题 I have a List component that displays multiple Item components. List gets its data from the Redux store. When the store is updated (because I deleted an item for example), all Item s are re-rerendered. Why is that? I know I could use shouldComponentUpdate() to prevent a new rendering, but I thought Redux would do it internally. List.js import React, { PropTypes, Component } from 'react'; import { connect } from 'react-redux'; import Item from './Item'; class List extends Component { render()

How to add event listener to redux form

▼魔方 西西 提交于 2020-07-22 04:30:37
问题 I am trying to pass the keydown event to redux form but I am at a loss. Could some one please help me how to resolve this issue? Actually, I want to alert when user hit enter in redux form. <div className="col-sm-3"> <Field name={`${item}.value`} type="text" component={renderField} keyDown={() => alert("what ar eyou")} normalize={normalizeDropdown} label="Values" /> </div> 回答1: <Field name={`${item}.value`} type="text" component={renderField} onKeyDown={(e) => handleKeyDown(e)} normalize=

How to add event listener to redux form

旧巷老猫 提交于 2020-07-22 04:29:01
问题 I am trying to pass the keydown event to redux form but I am at a loss. Could some one please help me how to resolve this issue? Actually, I want to alert when user hit enter in redux form. <div className="col-sm-3"> <Field name={`${item}.value`} type="text" component={renderField} keyDown={() => alert("what ar eyou")} normalize={normalizeDropdown} label="Values" /> </div> 回答1: <Field name={`${item}.value`} type="text" component={renderField} onKeyDown={(e) => handleKeyDown(e)} normalize=

Redux does not update state immediately

本小妞迷上赌 提交于 2020-07-21 07:30:11
问题 I have a problem with Redux, even more likely not a problem but a misunderstanding. If I do dispatch in a function and write a new value in the store then I can not immediately get into this function a new value from the store. Example: testFunc = () => { console.log('in func: before', this.props.count); //state store this.props.onButtonIncrementClick(); //dispatch a new state in the store console.log('in func: after', this.props.count); //get the old state store }; Live example: https:/

Updating state managed by another reducer

浪尽此生 提交于 2020-07-17 06:45:25
问题 In my React app, my appReducer manages global stuff such as notifications, user info, etc. One of the modules in the app is the inventory module which has its own reducer i.e. inventoryReducer. And in the redux store, I combine all the reducers. My questions is this: when a user makes an inventory entry, in addition to handling the inventory transaction, I want to display an on-screen notification which is handled in the appReducer. How do I update the state of displayNotification which is

How do I stop a component rendering before data is fetched?

蓝咒 提交于 2020-07-17 05:54:32
问题 Currently in react I have to functions in the componentDidMount lifecycle method in which call action creators to which fetch data. The component uses the data however, depending on how quick the response is determines if the data is there or not. How can i make it so the component doesn't render before data is inside it? componentDidMount() { this.props.getTotalHours() this.props.getTrained() } Render Function: render() { let hours = parseInt(_.map(this.props.hours, 'hours')); let trained =

How do I stop a component rendering before data is fetched?

守給你的承諾、 提交于 2020-07-17 05:53:33
问题 Currently in react I have to functions in the componentDidMount lifecycle method in which call action creators to which fetch data. The component uses the data however, depending on how quick the response is determines if the data is there or not. How can i make it so the component doesn't render before data is inside it? componentDidMount() { this.props.getTotalHours() this.props.getTrained() } Render Function: render() { let hours = parseInt(_.map(this.props.hours, 'hours')); let trained =