Questions tagged [react-lifecycle]

313 questions
1
vote
2 answers

How to use setState() inside compoentWillMount ReactJS

I'm new to ReactJs. I'm trying to create a firebase app using it. So in componentWillMount I'm checking if the user is logined or not and setting the state boolean value according to that componentWillMount() { var config = {...}; …
Bucky
  • 1,116
  • 2
  • 18
  • 34
1
vote
1 answer

React check api request before pass props to Children

I have a Parent component and Child one, and I have action that trigger some api call in Child component and on componentWillMount I check in if condition some props that come from parent and do some trigger. If condition true I trigger a method…
Palaniichuk Dmytro
  • 2,943
  • 12
  • 36
  • 66
1
vote
2 answers

How to access variable values inside componentWillMount() in reactjs

I'm assigning values inside my componentWillMount like shown in below componentWillMount() { /*this.props.fetchMetaData(this.props.url);*/ axios.get(`https://api.microlink.io/?url=${this.props.url}`) .then(res => { …
CraZyDroiD
  • 6,622
  • 30
  • 95
  • 182
1
vote
1 answer

How do I render the my latest data through GET request after submitting a POST request

I am having some difficulties with Reactjs lifecycles. I have my front-end and back-end all set up but I can't figure out how to re-render the latest data after submitting a new data through POST request. I am currently using componentWillMount to…
1
vote
1 answer

How do I properly dispatch actions inside the React Lifecycle Methods?

How do I properly dispatch actions in React Lifecycle Methods? Hello, friends I have an action called checkSession() inside my very parent component (App.jsx). This action helps me to get user info. This is how App.jsx looks like: class App…
jsDev
  • 136
  • 2
  • 12
1
vote
0 answers

Re-rendering component when props updates with createStructuredSelector

I will try and make this as short and sweet as possible while being detailed and descriptive. When my application initializes or loads for the first time, it makes an api call to fetch some blog data. Here is what that looks like more or less: As…
Nappstir
  • 995
  • 2
  • 20
  • 38
1
vote
3 answers

Can only update a mounted or mounting component error. Conditional rendering

So I have a login page that directs users to a profile page in which an asynchronous request is made retrieving a user's id number initiated at the componentDidMount event. Once I get the results back, I setState on the id with the data…
1
vote
1 answer

react-lifecycle-component have props in componentDidMount

I'm using react-lifecycle-component in my react app, and incurred in this situation where I need the componentDidMount callback to load some data from the backend. To know what to load I need the props, and I can't find a way to retrieve them.…
Don Giulio
  • 2,946
  • 3
  • 43
  • 82
1
vote
2 answers

conditional async actions in componentDidMount lifecycle method keeps going on a loop

I am working on a react app using redux and sagas connected to an API. There's a form component that has two dropdown fields: a Program and a Contact field. The way the form is designed to work is, when the user selects a program, the form uses the…
Ragav Y
  • 1,662
  • 1
  • 18
  • 32
1
vote
2 answers

React lifecycle

I use this to method to work with component, the componentWillMount to initialize data for homepage and the componentWillReceiveProps when router change (category page), but when I come back home page from category page, I know because…
1
vote
2 answers

why we prefer to write header or api request or ajax code in componentDidMount not in componentWillMount

why we prefer to write header or api request or ajax code in componentDidMount not in componentWillMount. need simple and clear difference with example
dxtmhjn
  • 33
  • 4
0
votes
0 answers

Mounting & Unmounting Process in functional components

I have the following Components and I am confused on how the mounting and unmounting actually works in react/react-native. const App = ()=>{ return ( ) } const…
0
votes
0 answers

State inside loop that is running inside async function doesn't change

I have two functions one function to fetch data using API inside the loop and a second function that changes a state cancel from false to true. But that state doesn't update inside that loop hence I cannot stop the API call. Below is the template…
Syed
  • 1
0
votes
1 answer

React useEffect and react-redux dispatch

I'm trying to put canvas and tool state using React and React Redux tools. I've a few components including this board.jsx: import React, { useRef, useEffect } from 'react'; import './Board.scss'; import { useSelector, useDispatch } from…
0
votes
0 answers

Rendering a list that is stored in a state using Redux, list has onClick function but it does not work when list is filtered(state change)

I am using React, tailwind and Redux to create a dropdown with filtering search. I know there can be other methods to do this like Select tag or using tailwind components already out there however I'm in too deep trying to figure out the issue as…