reactjs

React images load locally but not on AWS Amplify

ぃ、小莉子 提交于 2021-02-11 06:18:26
问题 Hi I am working with an API that retrieves the URL of an image. I am then trying to pass that URL into an tag as follows: <img class="img-fluid" src={this.state.representatives[i].pic}/> Locally I am met with But when I try to use the app on AWS Amplify, I am met with: I have tried hardcoding the URL into the app but it returns the same error. I am really confused where to go from here. For example the image URL pulled from the API for Mark Warner is http://bioguide.congress.gov/bioguide

Get route params inside actioncreator/selector?

心不动则不痛 提交于 2021-02-11 06:18:16
问题 Using redux router, In my components I have access to the params object with information about by URL. However, inside my actioncreators, I get the state through getState() , and thus the params props has not been injected. Is there a way around this? 回答1: to get access params in action creators, you should pass it: in component this.props.someAction(this.props.params) in action creator const someAction = (params)=>{ let {data} = params; .... } to get access params in selector, you should

React app not rendering in IE 11 even with polyfills

无人久伴 提交于 2021-02-11 06:13:34
问题 I have a fully built React application that I would like to deploy on IE 11, but been having no success but a white page. For the sake of testing, I created a dummy app using npx create-react-app and attempted to launch on IE 11/Edge. Installing 'react-app-polyfill' and importing on 'react-app-polyfill/ie11' and 'react-app-polyfill/stable' on line 1 & 2 of index.js, I also included "last 1 ie version" in the browserlist.development inside the package.json file. Every resource online points to

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

state is not being updated when using React Hooks

泄露秘密 提交于 2021-02-11 06:07:01
问题 I am currently playing around with the new React Hooks feature, and I have run into an issue where the state of a functional component is not being updated even though I believe I am doing everything correctly, another pair of eyes on this test app would be much appreciated. import React, { useState, useEffect } from 'react'; const TodoList = () => { let updatedList = useTodoListState({ title: "task3", completed: false }); const renderList = () => { return ( <div> { updatedList.map((item) =>

stop handleBlur from doing anything

我怕爱的太早我们不能终老 提交于 2021-02-11 05:07:56
问题 In my Formik form, when I click on the search button, a list of items is rendered (UsersFoundList). This list is outside the form and each item in the list has a button of its own. When I click on any of those buttons from the list for the first time, they don't work. Instead, the handleBlur of my form is triggered and since the input field is empty, an error messages starts showing under the input field. So, the button doesn't do what it's supposed to do in the first attempt. I tested the

stop handleBlur from doing anything

笑着哭i 提交于 2021-02-11 05:01:49
问题 In my Formik form, when I click on the search button, a list of items is rendered (UsersFoundList). This list is outside the form and each item in the list has a button of its own. When I click on any of those buttons from the list for the first time, they don't work. Instead, the handleBlur of my form is triggered and since the input field is empty, an error messages starts showing under the input field. So, the button doesn't do what it's supposed to do in the first attempt. I tested the