Questions tagged [react-lifecycle]
313 questions
0
votes
1 answer
Next.js data loading Issue
I face an issue with Next.JS and fetching initial props to my pages. I am doing an application with several (7-8) pages. One the left menu, once a an icon is clicked, the router is pushing the user to the proper page. Then if the user is logged in,…

Koppany
- 57
- 9
0
votes
2 answers
Why isn't my React child component receiving new props?
I have a React component that acts as a sortable table. The table header and the table rows are children of a container, and the container is handling the state of the table. When a header is clicked, the data is re-ordered just like it is in this…

Michael O'Connell
- 19
- 5
-1
votes
1 answer
How do I show details of a loading process while data is loading in useEffect?
When a particular custom React component I have first mounts, it uses useEffect to kick off a long multistep process of loading data that it will then render. The component isn't always rendered, so this expensive process isn't always needed. The…

WBT
- 2,249
- 3
- 28
- 40
-1
votes
1 answer
Trouble updating arrays when page reloads
So I'm trying to build a blackjack game in React. And I'm having trouble figuring out how to update the player and dealer hands when the page reloads or the player asks to take a hit. I've been experimenting with the useEffect hook but my IDE…

pdrake1988
- 43
- 8
-1
votes
1 answer
React life cicle and AsyncStorage
I'm creating an app which passes some crucial info via AsyncStorage, but now have a problem when updating it on another screen.... Let's see:
On Screen 1 :
Load data from AsyncStorage on componentDidMount
componentDidMount() {
…

Marco Martin
- 185
- 1
- 4
- 18
-1
votes
3 answers
Using state with componentDidMount
I want to fetch data that returns successfully after componentDidMount, but before there is an error that singer.data is undefined:
// imports
export default class LookSinger extends Component {
state = {
singer: {}
}
…

s662720h_uu
- 33
- 6
-1
votes
1 answer
Purpose of componentWillReceiveProps/getDerivedStateFromProps
I'm just learning React and I've come across something I can't find explained anywhere.
In every book/blog that I've read about React components I've seen a statement along the lines that component props are immutable. The only way to change a…

melston
- 2,198
- 22
- 39
-1
votes
1 answer
Why is the react component is rendering twice without changing the state?
First i added logs in the console for every life cycle hooks
class CircleA extends Component {
constructor(props) {
super(props);
this.state = {
name: "Circle",
};
console.log("Circle-A constructor");
}
static…
user8368085
-1
votes
1 answer
Can I get the data from database that makes an API call then pass it to another function that makes an another API call
In react, I want to get data from a database.
I attempted to get the data from database using getCoor() and put in the constructor method.
I defined variable
private data:any=[];
and defined a state, this.state={data:[]}
Here I am trying to
Get…

Random I.T
- 121
- 1
- 10
-1
votes
3 answers
Calling setState in constructor gives warning
I have a code written by someone else where the constructor where I havestate initialized but also called the setState if props is undefined, the code is as below:
constructor(props) {
super(props);
this.state = {
subId:…

OM The Eternity
- 15,694
- 44
- 120
- 182
-2
votes
2 answers
pending promise inside async/await
I wast trying to fetch some data in componentDidMount and then set it to state, wrote an async await function for the same. But if i was trying to set the state with the values right after await, the value was getting set to a pending promise but…

discoveranirban
- 1
- 1
-2
votes
1 answer
How to re-render the same component on React?
Well I am making this weather app with the use of an api. So, first I have to show the weather of a default city. Then when I select the other cities, the component will render again to give me the weather data of selected cities.
So far I have done…

tanjim anim
- 337
- 3
- 23
-2
votes
2 answers
React console.log(i) print the previews result
With the code below - handleChange methos is used in form fields:
starting i = 0
with the first change
i should get updated with i+1
and console.log(i) = should be 1, but get 0
I tried to research the lifecycles and read a lot of posts, but…

Eliran Nider
- 75
- 9