Questions tagged [react-lifecycle]

313 questions
0
votes
0 answers

API is getting called multiple times inside componentDidMount

I have written a method like below but i am noticing my API is getting called multiple times. I am calling my API inside componentDidMount(). class User extends Component { state = { cardData: [], }; userDetails = async () => { const…
techie_questie
  • 1,434
  • 4
  • 29
  • 53
0
votes
1 answer

Google signin is not working properly on ComponentDidMount

componentDidMount() { window.gapi.load("client:auth2", () => { window.gapi.client .init({ clientId: process.env.REACT_APP_CLIENT_ID, scope: "email" }) .then(() => { …
Ashik
  • 2,888
  • 8
  • 28
  • 53
0
votes
3 answers

ComponentDidMount not working and no error is displaying

class Clock extends React.Component { state = { time: new Date().toLocaleTimeString() }; componentDidMount() { setInterval(() => { this.setState = ({ time: new Date().toLocaleTimeString()}) }, 1000) } render() { return ( …
0
votes
3 answers

React Native lifecycle method to execute navigation code (navigate to other screen) after completion of redux cycle

I am using Redux and React Navigation in my app where I am making some API calls, I have a question that after successful completion of my redux cycle which lifecycle method of react component I should have to use for navigation to the next screen…
Bhagwat K
  • 2,982
  • 2
  • 23
  • 33
0
votes
2 answers

Making independent copies inside componentDidMount()

I am new to javascript and react (16.9.0), so I hope this question is not too obvious: I know I can make a copy of a dictionary with '...', example: const dict_new = {...dict_old} I am using this expression to avoid a referenced copy. The problem…
chococroqueta
  • 694
  • 1
  • 6
  • 18
0
votes
2 answers

Lifecycle Management in React-native

What is the life cycle when exiting an app with Swipe in Ios Simulator? I tried to log every lifecycle, but nothing happened. I want to execute a specific function when the app exits, but I'm not sure what to do. Has anyone had a similar problem…
sera
  • 73
  • 1
  • 9
0
votes
1 answer

Why getSnapshotBeforeUpdate is nedded in react

I am learning to react lifecycle methods but stuck at a query and not able to find the answer even after lots of research over the web. As per the react official documentation here, it is said that the method getSnapshotBeforeUpdate is used to…
Rahul Agarwal
  • 41
  • 1
  • 7
0
votes
1 answer

Why is the recipes not showing in the application after I fill in the state with the response in componentDidMount

The ingredients data is not showing on the page after I call the setState method to the this.state.ingredients I have tried to change the different parameters in my code such as res.data.recipes, etc import React from 'react'; import Form from…
Kenny Q
  • 31
  • 1
  • 7
0
votes
2 answers

react-native componentWillUpdate, componentWillReceiveProps - Warning

react-native (componentWillUpdate, componentWillReceiveProps) swipe function app. Warning: componentWillReceiveProps is deprecated and will be removed in the next major version. Use static getDerivedStateFromProps instead. Warning:…
김회준
  • 149
  • 3
  • 13
0
votes
1 answer

Trying to use a function that is in my context provider file

I am using Context-Api and am trying to use a function provided from my file in a lifecycle method. the function isnt wrapped in a consumer of course so i looked at the documentation and set value to context. this still isnt working.Everyting is…
0
votes
1 answer

React adding a new item for every `null` in the list of elements on every re-render

If you're mapping over an array to render elements and in the resulting array of elements you have a null and then 2 or more items with the same key, on each re-render, React will add another element to the DOM like those two. Here's a minimal code…
Leo Brdar
  • 3
  • 3
0
votes
1 answer

How to get prop values from reducer before render() is executed?

I used redux-thunk middleware and I'm receiving the values from props only after the render is executed. How can i get the values of 'Contents' to be set in props before render is called?? UNSAFE_componentWillMount() { …
0
votes
2 answers

How to get height of an element at each page update

I have a content area on my page that displays data that gets to be pulled through from an API. I hooked it up so once data gets pulled from the API, it gets saved to the Redux store and page displays it. Now, I need to add a scroll to top and…
Extelliqent
  • 1,760
  • 5
  • 32
  • 51
0
votes
1 answer

Assignment of value in ComponentDidMount instead of constructor function in React

Following is my code (which is working fine) in which I am able to sort list on the basis of input provided in text box. In constructor method I declared my states like this - this.state = { data: ["Adventure", "Romance", "Comedy", "Drama"], …
Nesh
  • 2,389
  • 7
  • 33
  • 54
0
votes
1 answer

How to change react-router-native location on native-module callback

I'm building a react-native application that displays Service overlay (like those facebook messenger bubble heads), implement in Android only, and on the overlay click it should go back to the app in a specific screen. I'm using react-router-native…
Thiago Loddi
  • 2,212
  • 4
  • 21
  • 35