Questions tagged [react-lifecycle]
313 questions
0
votes
0 answers
how to stop map component re-mount after the state update (react-google-maps)
I use 'react-google-maps'
There are some checkboxes and one GoogleMap component in my page.
When I update react state after I click checkbox. The GoogleMap will unmount and mount again. The GoogleMap doesn't use the state which be changed by…

Hsueh-Jen
- 267
- 2
- 9
0
votes
1 answer
What is the best way to compare between the many prevProps and nextProps in Reactjs?
The child component is receiving many updated props from its parent component.I want to update the child component if there is any update in the props.Currently,i'm doing it using the life cycle method componentWillReceiveProps which is working as…

CodeZombie
- 2,027
- 3
- 16
- 30
0
votes
1 answer
Firing 2 Redux Actions , only 1 action is fired
I've fired an action in componentDidMount :
componentDidMount() {
this.props.getQuests();
}
and would like to fire another action once it's completed, I've used the lifecycle method componentWillReceiveProps
componentWillReceiveProps = async…

Ash Rhazaly
- 205
- 3
- 14
0
votes
1 answer
Curried function not getting called in componentDidMount
componentDidMount() {
this.onRefresh(this.props.subdomainConfig)
}
onRefresh = config => () => {
console.log('onRefresh', config)
}
In this react component the onRefresh function is not getting called at all when component mounts. If I use…

Aman Agarwal
- 589
- 1
- 4
- 22
0
votes
2 answers
getDerivedStateFromProps not working for my application. How can I replace componentWillRecieveProps?
I'm creating a React application with Redux, and on my Account Settings page I have a form that I want pre-populated with the user's info and then give them the ability to edit the fields and update their profile. My code is as follows:
class…

Adam Johnston
- 1,399
- 2
- 12
- 23
0
votes
1 answer
React setState to value received from http response
First of all, please excuse me english, i am not a native speaker.
I will try to explain my best.
I am trying to set the state of my component to a value received from http request that runs on componentDidMount(). After setState, i am passing props…

kevin janada
- 41
- 1
- 2
- 10
0
votes
1 answer
React Native: How to handle the deprecation of the lifecycle methods with ListView?
I'm currently learning React Native. I want to write a ListView. The tutorial I'm following uses the deprecated method componentWillMount, which is now called UNSAFE_componentWillMount. I googled an people said one should replace that method with…

J. Hesters
- 13,117
- 31
- 133
- 249
0
votes
1 answer
react-native-camera barcode scanner freezes, because it scans too fast
I am trying to use the barcode scanner from react-native-camera. First, off it scans a QR-code and extracts a String, after that it navigates to the next Screen with react-navigation. In the second screen, it makes an API-call.
Now if I go back to…

Fabio ha
- 553
- 1
- 8
- 29
0
votes
2 answers
componentWillMount check on undefined before api request will resolve
I have a component that triggers some methods that depend on async API request. I use componentWillmount to check some props. If this prop is true I trigger some function otherwise false. But the problem is, that first time the prop is undefined,…

Palaniichuk Dmytro
- 2,943
- 12
- 36
- 66
0
votes
1 answer
Tracking changes on one property in state
I have a state with different properties. I want to listen and fire an action when only one particular property in state changes. This property is array of objects and when it changes I want to send that new updated property to parent component. How…

Igor-Vuk
- 3,551
- 7
- 30
- 65
0
votes
0 answers
React app componentDidMount rendering twice
I've got a simple react app that has a Login that receives a Json Web Token on successful authentication and the passes it to a sibling component (Members) that in its componentDidMount uses this JWT to make a fetch call to the server. The thing is…

Dieguinho
- 758
- 2
- 14
- 31
0
votes
0 answers
React ref not being called before componentDidMount
I'm trying to follow this example in my project but I couldn't make it work https://react-slick.neostack.com/docs/example/as-nav-for
I think the reason is:
It needs a ref to both objects to sync them
It is supossed to be synced with the state…

Jumper
- 151
- 1
- 14
0
votes
1 answer
ComponentWillReceiveProps are changing my props which I was getting from API
In my ComponentWillReceiveProps() methods my prop are getting updated which was fetched from API only. Please help how to recover the props.
My ComponentWillReceiveProps():
constructor(props) {
super(props)
this.state = {
…

Tarik Sahni
- 158
- 1
- 2
- 13
0
votes
1 answer
onClick function in react on a button can only be fired once
I have an onClick function that changes a className's state so show and hide some stylings that I have. The button works fine on the first click, but can't be clicked again after that.
Shown below I have my component that connects to my redux store.…

Nate Watts
- 351
- 1
- 3
- 6
0
votes
1 answer
How to cause the component to re-render after an ajax request
Rerendering same component inside one function in ReactJs. I'm adding comment and now after that I want to rerender the same component. Can anyone help?
commentPost() {...
axios.defaults.headers.common['Authorization'] = getToken;
…

Riya Kapuria
- 9,170
- 7
- 18
- 32