redux

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:/

Saga watcher not receiving or processing dispatched action

本秂侑毒 提交于 2020-07-21 07:28:50
问题 I have a watcher saga that is constantly listening for actions of a certain type. This is started up from the saga.run(). When it receives an action of a certain type, it should then call into another saga which performs async actions. However a breakpoint inside the second saga is never getting called. So either the originating code is not dispatching the action correctly, or the watcher saga is configured wrong. Watcher saga code import { all, fork, takeLatest } from 'redux-saga/effects'

Saga watcher not receiving or processing dispatched action

倾然丶 夕夏残阳落幕 提交于 2020-07-21 07:28:45
问题 I have a watcher saga that is constantly listening for actions of a certain type. This is started up from the saga.run(). When it receives an action of a certain type, it should then call into another saga which performs async actions. However a breakpoint inside the second saga is never getting called. So either the originating code is not dispatching the action correctly, or the watcher saga is configured wrong. Watcher saga code import { all, fork, takeLatest } from 'redux-saga/effects'

Declaring function inside function in React

浪尽此生 提交于 2020-07-20 20:35:18
问题 I just came across a React code and I'm not sure whether it's is a good way to do it or not. This is a sample implementation of that code. class App extends React.Component { renderMessage = () => { function getMessage() { return "Hello" } function getName() { return "Vijay" } return ( <h1>{getMessage()} {getName()} !!!</h1> ) } render() { return ( <div> {this.renderMessage()} </div> ) } } Here we are calling a function renderMessage inside render. In renderMessage there are two inner

Declaring function inside function in React

别等时光非礼了梦想. 提交于 2020-07-20 20:35:01
问题 I just came across a React code and I'm not sure whether it's is a good way to do it or not. This is a sample implementation of that code. class App extends React.Component { renderMessage = () => { function getMessage() { return "Hello" } function getName() { return "Vijay" } return ( <h1>{getMessage()} {getName()} !!!</h1> ) } render() { return ( <div> {this.renderMessage()} </div> ) } } Here we are calling a function renderMessage inside render. In renderMessage there are two inner

React Warning: Cannot update a component from inside the function body of a different component

江枫思渺然 提交于 2020-07-20 07:32:10
问题 I am using Redux with Class Components in React. Having the below two states in Redux store. { spinner: false, refresh: false } In Parent Components, I have a dispatch function to change this states. class App extends React.Component { reloadHandler = () => { console.log("[App] reloadComponent"); this.props.onShowSpinner(); this.props.onRefresh(); }; render() { return <Child reloadApp={this.reloadHandler} />; } } In Child Component, I am trying to reload the parent component like below. class

Delete data from Firestore dynamically

懵懂的女人 提交于 2020-07-19 19:01:10
问题 I'm building a project with React & Redux & Firestore, I know how to delete/update/add etc.. But when I have 2 subcollections with dynamic field, I couldn't find any solution to delete it. If you look at the picture, I have the table ID and user ID, but the fields are 0, 1, 2 and so on. How can I delete a field from tableGuests? Maybe the structure is not good and could be better? guests > user id > userTables > table id > tableGuests which is an array. 回答1: How can I delete a field from

Delete data from Firestore dynamically

女生的网名这么多〃 提交于 2020-07-19 18:59:06
问题 I'm building a project with React & Redux & Firestore, I know how to delete/update/add etc.. But when I have 2 subcollections with dynamic field, I couldn't find any solution to delete it. If you look at the picture, I have the table ID and user ID, but the fields are 0, 1, 2 and so on. How can I delete a field from tableGuests? Maybe the structure is not good and could be better? guests > user id > userTables > table id > tableGuests which is an array. 回答1: How can I delete a field from

Function components cannot have refs. Did you mean to use React.forwardRef()?

一曲冷凌霜 提交于 2020-07-18 09:43:25
问题 Hi I am trying to choose file form my computer and display the file name on input field but I am getting this error Function components cannot have refs. Did you mean to use React.forwardRef() https://stackblitz.com/edit/react-aogwkt?file=bulk.js here is my code import React, { Component } from "react"; import { Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControl, IconButton, Input, InputAdornment, withStyles } from "@material-ui/core"; import Attachment from "@material-ui