react-redux

Calling an async redux action creator on form submission

和自甴很熟 提交于 2021-02-11 06:36:26
问题 In a typical React/Redux app it's pretty common to use redux-thunk and async action creators to trigger an AJAX request and dispatch actions on start/success/failure of this request. However, I can't find a way to integrate such a function with react-final-form. Its redux submission example is using react-redux-promise-listener which dispatches an action immediately, but does not let me call my async action creator. It is possible to integrate react-final-form with a redux app that uses an

How to test mapStateToProps using React Redux and Jest?

a 夏天 提交于 2021-02-11 06:11:51
问题 When I create a test for my connected React component where I want to test the mapStateToProps logic I run into a problem which I'm not sure how to solve. Error message Expected: 1 Received: undefined 24 | it('should show previously rolled value', () => { 25 | // test that the state values were correctly passed as props > 26 | expect(wrapper.props().lastRolledNumber).toBe(1); When I check the wrapper.props() it only returns the store object and no properties. To make sure it's not my code I

How to test mapStateToProps using React Redux and Jest?

♀尐吖头ヾ 提交于 2021-02-11 06:10:42
问题 When I create a test for my connected React component where I want to test the mapStateToProps logic I run into a problem which I'm not sure how to solve. Error message Expected: 1 Received: undefined 24 | it('should show previously rolled value', () => { 25 | // test that the state values were correctly passed as props > 26 | expect(wrapper.props().lastRolledNumber).toBe(1); When I check the wrapper.props() it only returns the store object and no properties. To make sure it's not my code I

How to test mapStateToProps using React Redux and Jest?

孤街醉人 提交于 2021-02-11 06:07:52
问题 When I create a test for my connected React component where I want to test the mapStateToProps logic I run into a problem which I'm not sure how to solve. Error message Expected: 1 Received: undefined 24 | it('should show previously rolled value', () => { 25 | // test that the state values were correctly passed as props > 26 | expect(wrapper.props().lastRolledNumber).toBe(1); When I check the wrapper.props() it only returns the store object and no properties. To make sure it's not my code I

How to test mapStateToProps using React Redux and Jest?

眉间皱痕 提交于 2021-02-11 06:07:21
问题 When I create a test for my connected React component where I want to test the mapStateToProps logic I run into a problem which I'm not sure how to solve. Error message Expected: 1 Received: undefined 24 | it('should show previously rolled value', () => { 25 | // test that the state values were correctly passed as props > 26 | expect(wrapper.props().lastRolledNumber).toBe(1); When I check the wrapper.props() it only returns the store object and no properties. To make sure it's not my code I

Building a Modal component in React without nesting it inside caller component

て烟熏妆下的殇ゞ 提交于 2021-02-10 14:33:51
问题 I'm trying to call a Modal from non-related component (without using any parent-child relationship). In order to do that I'm trying to use React Redux (as the only way I've seen that can make a connection between two unrelated components). An example on CodeSandbox shows the bare minimum of what I'm trying to do. My issue is that I don't want to include <Modal> inside the <Button> render function. I want to be able to simply flip the flag in Button.js and <Modal> would appear. This is, from

Arrow function should not return assignment no-return-assign

自闭症网瘾萝莉.ら 提交于 2021-02-10 11:51:16
问题 My code is working correctly in the app however, before commit husky runs and gives out the error saying "Arrow function should not return assignment no-return-assign" <Field name='dob' label='dateOfBirth' placeholder='' onFocus={(e) => e.target.placeholder = 'MM/YYYY/DD'} /> 回答1: As several people mention in comments, the issue is that you're using (e) => e.target.placeholder = 'MM/YYYY/DD' which is roughly equivalent to anon_func = function (e) { return e.target.placeholder = 'MM/YYYY/DD';

Arrow function should not return assignment no-return-assign

三世轮回 提交于 2021-02-10 11:48:31
问题 My code is working correctly in the app however, before commit husky runs and gives out the error saying "Arrow function should not return assignment no-return-assign" <Field name='dob' label='dateOfBirth' placeholder='' onFocus={(e) => e.target.placeholder = 'MM/YYYY/DD'} /> 回答1: As several people mention in comments, the issue is that you're using (e) => e.target.placeholder = 'MM/YYYY/DD' which is roughly equivalent to anon_func = function (e) { return e.target.placeholder = 'MM/YYYY/DD';

React TypeError: Class constructor Fullpage cannot be invoked without 'new'

北战南征 提交于 2021-02-10 07:50:34
问题 When I use tag as shown below, I'm getting this error! React TypeError: Class constructor Fullpage cannot be invoked without 'new' It looks like something went wrong in line 1438: renderWithHooks node_modules/react-dom/cjs/react-dom.development.js:14803 this is my Fullpage.js file: import React, {Component} from 'react'; import './Fullpage.css' class Fullpage extends Comment{ render(){ const {children}=this.props return( <div className={`fullpage ${this.props.className || ''}`}> {children} <

Nesting `combineReducers` doesn't let to have state without nested objects

荒凉一梦 提交于 2021-02-10 07:26:09
问题 I have bookManageReducer.jsx : import { combineReducers } from 'redux' import { REQUEST_BOOKS_PAGE, RECEIVE_BOOKS_PAGE } from '../constants/dashboardConstants' const books = (state = [], action) => { switch (action.type) { case RECEIVE_BOOKS_PAGE: return action.books default: return state } } const booksState = (state = {isFetching: false}, action) => { switch (action.type) { case REQUEST_BOOKS_PAGE: return {isFetching: true} case RECEIVE_BOOKS_PAGE: return {isFetching: true} default: return