Questions tagged [react-lifecycle]

313 questions
1
vote
3 answers

Why the componentDidUpdate is infinitely updated?

I need to drop a picture, then upload it to the server and update the interface. I have a problem, the lifecycle method componentDidUpdate is beginning to be updated infinitely, in the condition I indicated to compare this.state with the prevState.…
1
vote
3 answers

API call on event in react, componentDidUpdate or eventHandler?

Where should we ideally place an api call to be made on occurrence of an event in React Inside the eventHandler or componentDidUpdate ? example: handleItemClick = (item) => (event) => { this.setState({selectedItem: item}); …
Rahul Yadav
  • 2,627
  • 5
  • 30
  • 52
1
vote
3 answers

alternative for this componentWillMount case?

I'm trying to refactor some old code. componentWillMount has been deprecated. How would I refactor it here into something else? class Detail extends React.Component{ constructor(props) { super(props); this.state = { …
thanks_in_advance
  • 2,603
  • 6
  • 28
  • 44
1
vote
1 answer

React: setState is not rendering the page again

I am struggling with React and the lifecycles. I try to implement a very simple Next button which shows the next page with a next set of items. When I change manually the state offset to 3, the page is rendered correctly with the next items. But…
Rogier
  • 905
  • 1
  • 10
  • 25
1
vote
4 answers

Why component update lifecycle executes whenever parent's state changes?

I have a parent component called 'App' in which a child component is used called 'NewComp'.I have defined componentDidUpdate() lifecycle inside child component,not in parent component. Parent component: class App extends Component { state = { …
ShahEryar Ahmed
  • 115
  • 1
  • 2
  • 10
1
vote
1 answer

Uncaught RangeError: Maximum call stack size exceeded - ReactJS

I have gone over all questions like mine, but couldn't find anything useful for this case. Please help. This is my function: renderFields() { if (this.props.field) { // some prop return (
dututu
  • 41
  • 6
1
vote
3 answers

how to prevent children component re render, when state/props parent component changing?

right now im have tree component like this im take props from redux in UserOrderApproval component, and passing that…
Endy Santoso
  • 591
  • 7
  • 21
1
vote
2 answers

Change react props within component as optimization

Problem *That is not exactly my case but here is what matters. Imagine an app that renders a list of elements: const ElementsList = ({elements, }) => (
{elements.map(el => (
1
vote
2 answers

Calling a function each time a component is rendered, since componentDidMount() only triggers once

EDIT: Upon further testing i realized that componentDidMount IS behaving how i was expecting, but it seems to be a problem with my randomizing function that for some reason returns undefined if it gets run a second time, so on initial mount it gives…
xunux
  • 1,531
  • 5
  • 20
  • 33
1
vote
0 answers

React avoidable re-rendering problem with AntDesign and PrimeReact

We are developing a huge application with React. One of our forms includes 60+ plus components placed on different Tab items. When i try to edit an input it took 190ms to see typed chars in the textbox. After digging the problem for hours we…
1
vote
1 answer

How to wait till service call completes before loading next page in react router

I have an issue with an app with four forms. Each page of the form does a POST when the component unmounts. It was business requirement that anytime the user leaves the page, the form info is POSTed, so I cannot move the logic to the 'NEXT' button I…
1
vote
1 answer

Using new lifecycle methods for fetching data by a changing id in React + Redux

I have done it like this in React <= 16.2 : componentDidMount () { fetchData(this.props.id) } componentWillReceiveProps(nextProps) { if (this.props.id !== nextProps.id) { fetchData(nextProps.id) } } render() { if (this.props.isLoading)…
vinczemarton
  • 7,756
  • 6
  • 54
  • 86
1
vote
2 answers

How to update the header while the component is still rendered using React Navigation?

I'm writing a React Native app and I'm using React Navigation (V2) with it. I want to update the navigationOptions and add a new button, after my component has updated. Here is the code with which I tried it: static navigationOptions = ({…
J. Hesters
  • 13,117
  • 31
  • 133
  • 249
1
vote
2 answers

Pasing fetched data as props (a JSON) to state in order to render data

Currently I get my data from an API in a JSON-format when running my saga. The fetching process begins, when the component did mount. That means the component renders two times. Now, when the data is available as props. I can use it in order to…
1
vote
0 answers

Should I be using an Event Listener or should this be in a Life Cycle method in React?

I have a component which renders a form. This form can spit back the distance between a collection of predetermined airports. { JFK: { LAX: 2475, LAS: 2248, PDX: 2454 }, LAX: { JFK: 2475, LAS: 236, PDX: 834 }, LAS: { JFK: 2248, LAX: 236, PDX:…
Antonio Pavicevac-Ortiz
  • 7,239
  • 17
  • 68
  • 141