reactjs

react select onChange returning previous value instead of current

偶尔善良 提交于 2021-02-13 17:37:38
问题 I'm attempting to update the state of a parent component after a user changes the value of a child components select element. While I've got it somewhat working, I've noticed that when I fire the onChange event on my select element it'll return the previous value instead of the one that has just been selected. My React Code class Parent extends React.Component{ constructor(props){ super(props); this.state = { data: { condition: "any" } }; } update = data => { this.setState({ data: { ...this

react select onChange returning previous value instead of current

余生颓废 提交于 2021-02-13 17:36:14
问题 I'm attempting to update the state of a parent component after a user changes the value of a child components select element. While I've got it somewhat working, I've noticed that when I fire the onChange event on my select element it'll return the previous value instead of the one that has just been selected. My React Code class Parent extends React.Component{ constructor(props){ super(props); this.state = { data: { condition: "any" } }; } update = data => { this.setState({ data: { ...this

Firebase storage: download images to and put to img src in React map

 ̄綄美尐妖づ 提交于 2021-02-13 17:34:18
问题 I'm trying to map array to get image url from Firebase storage and list them to page. The code give me a url, but the problem is that code not set url to img variable on time and returning empty img variable. return( <div> <Header /> {this.state.loaded ? <Loading /> : null} <div> {this.state.productsArr.map((product, i) => { let img = ''; storageRef.child(`images/${product.images[0]}`) .getDownloadURL() .then((url) => { img = url console.log('then img', img) }) .catch((err) => console.log(err

How to hide componentWillMount warnings

若如初见. 提交于 2021-02-13 11:30:09
问题 I'm getting four big warnings that can not be minimized in my console. These warnings are from what I understand not because I have done anything wrong, but because react-router-dom and react-select use the deprecated componentWillMount function. How do I get rid of the warnings? I have tried looking up the problem on this site, but the closest to a solution I have found is https://stackoverflow.com/a/49166225/12057512. Since the answer is from over a year ago I am wondering if this is still

React.js - Passed function “not a function” Error

家住魔仙堡 提交于 2021-02-13 05:37:50
问题 I am trying to pass props from a child component to a parent component, but for some reason I'm getting the error "TypeError: this.props.onClick is not a function" in the js console after clicking on the rendered child components. Basically what I am trying to do is manage a list of categories in which one category subcomponent has the 'selected' prop as true, and updates correctly every time you click on a category li. Here is a jsfiddle with the code: http://jsfiddle.net/kb3gN/8023/ I don't

React.js - Passed function “not a function” Error

∥☆過路亽.° 提交于 2021-02-13 05:37:06
问题 I am trying to pass props from a child component to a parent component, but for some reason I'm getting the error "TypeError: this.props.onClick is not a function" in the js console after clicking on the rendered child components. Basically what I am trying to do is manage a list of categories in which one category subcomponent has the 'selected' prop as true, and updates correctly every time you click on a category li. Here is a jsfiddle with the code: http://jsfiddle.net/kb3gN/8023/ I don't

How to update Firebase data to the React application in realtime

十年热恋 提交于 2021-02-12 09:27:22
问题 I'm developing an application that updates Firebase data in realtime to React. What I want to do is that a user updates the state in the app, at the same time it should be updated for another user. I have built it done but it continually renders renderStatus() and it's too slow. I want to make it updated once RDB data updated. class Status extends Component { constructor(props) { super(props); this.state = { to_status: false, from_status: false }; } // change the state in RDB handleSatus = ()

How to update Firebase data to the React application in realtime

雨燕双飞 提交于 2021-02-12 09:27:11
问题 I'm developing an application that updates Firebase data in realtime to React. What I want to do is that a user updates the state in the app, at the same time it should be updated for another user. I have built it done but it continually renders renderStatus() and it's too slow. I want to make it updated once RDB data updated. class Status extends Component { constructor(props) { super(props); this.state = { to_status: false, from_status: false }; } // change the state in RDB handleSatus = ()

How to update Firebase data to the React application in realtime

南笙酒味 提交于 2021-02-12 09:24:39
问题 I'm developing an application that updates Firebase data in realtime to React. What I want to do is that a user updates the state in the app, at the same time it should be updated for another user. I have built it done but it continually renders renderStatus() and it's too slow. I want to make it updated once RDB data updated. class Status extends Component { constructor(props) { super(props); this.state = { to_status: false, from_status: false }; } // change the state in RDB handleSatus = ()

How to update Firebase data to the React application in realtime

旧巷老猫 提交于 2021-02-12 09:23:20
问题 I'm developing an application that updates Firebase data in realtime to React. What I want to do is that a user updates the state in the app, at the same time it should be updated for another user. I have built it done but it continually renders renderStatus() and it's too slow. I want to make it updated once RDB data updated. class Status extends Component { constructor(props) { super(props); this.state = { to_status: false, from_status: false }; } // change the state in RDB handleSatus = ()