Questions tagged [react-lifecycle]

313 questions
0
votes
1 answer

Re-rending component when the state changes in a different reducer

Okies, So, I am working on a simple recipe collection App, where I have cuisineReducer.js and RecipeReducer.js. and on my admin Dashboard, an admin user is allowed to Create, Delete and Edit any Cuisine groups and also could Create, Delete and…
0
votes
1 answer

child component does not rerender with shouldComponentUpdate

My child component changes its state when its prop is changed. I want to re-render child component ImageSlide so call different string when state changes. The className is well changed and console shows the changed values well. But it does not…
심시은
  • 339
  • 1
  • 5
  • 21
0
votes
2 answers

How to clear the state so that the previous state doesn't render in the current component?

In my recipe app, when a user clicks on a particular recipe, it renders all the details of clicked recipe in a component recipeById. When I navigate back to landing page, and select another recipe, in my UI; it first renders the data of the…
Ada_lovelace
  • 637
  • 2
  • 6
  • 18
0
votes
0 answers

can i call ajax/http in constructor to populate some class variable but does not effect state in react

In a class component of react, i am getting one endpoint in props. i need to fetch that endpoint to get exact end points that will be used in links of that component. I am preferring to save the response in class variables not in state of…
0
votes
2 answers

Which DOM does react component render function refers to? real-dom or vitual-dom?

I have read lots of articles and believe this question is not the duplicated one. According to What is the role of the render() function inside react component? render function is part of the react component lifecyle where ReactDOM is the class…
jwkoo
  • 2,393
  • 5
  • 22
  • 35
0
votes
2 answers

How to fix recursively updating state?

I am bulding an app using newsapi. i am facing two issue on my state. i fetch data using api and assign it to my state. and use it in my view. Issue no 1 My view gets rendered before my app receives the data. Issue no 2 When I try to update my state…
user27019
  • 29
  • 7
0
votes
1 answer

Reactjs rerender component after CRUD Operation

I am building a login in with MongoDB as my database hosted on heroku. I want to change the value of my component after updating the property of my loggedin user in my DB. This is my function which updates the "Credits" of my…
Martin Seubert
  • 978
  • 3
  • 21
  • 37
0
votes
0 answers

Mounting and Unmounting component

i'm currently executing this.props.navigation.navigate('myView') using react-navigation. But when i leave and enter quickly to that view, in some cases a strange behavior occurs in the react-native life cycle. My logs: *When works normally: -…
jose920405
  • 7,982
  • 6
  • 45
  • 71
0
votes
1 answer

How to trigger if(this.props!==nextProps) in componentwillreceiveprops in Unit Testing?

I am new in Unit Testing for React. I have a question regarding the if statement. I need test the function of componentwillreceiveprops, I know I can use spy = sinon.stub(component.props,"componentwillreceiveprops") method to let spy be called. But…
0
votes
1 answer

memory increment of the application in the browser while running it for several hour

I am stuck with the memory increment of my application and as it is single page I can't even reload it. After running my application for around 5-6 hour memory size is reaching around 600mb from initial loading i.e 120mb and we did some fixed for…
Bishal Jain
  • 189
  • 1
  • 2
  • 10
0
votes
1 answer

How do you access the DOMNodes/refs of children in a React wrapper component?

class List extends Component { {this.props.list.map(item => } } class DoSomethingToList extends Component { componentDidUpdate(prevProps) { // I want to access…
Jeremy Gottfried
  • 1,061
  • 13
  • 28
0
votes
1 answer

Getting two outputs one before and one after componentDidMount

In the console I'm getting two outputs , one with empty array and another one with the updated array . I only need the updated array after the component did mount function.. How can I eliminate the first one... class App extends Component { …
ReNinja
  • 543
  • 2
  • 10
  • 27
0
votes
1 answer

React - Using componentDidUpdate to update state based on data passed from another function

I'm learning React and working on a John Conway's Game of Life app. I have a 2D array defined in the state/the constructor which creates a game board of squares. I have a function called isSquareAlive that handles whether or not a particular square…
Nick Kinlen
  • 1,356
  • 4
  • 30
  • 58
0
votes
1 answer

Declaration of constant in componentWillMount in React?

Which one is a better approach 1st or 2nd in terms of performance ? const getCookieValue = readCookie('my_var') should be declared at top or since its usage is only in a condition so better to keep it inside if statement Approach…
Nesh
  • 2,389
  • 7
  • 33
  • 54
0
votes
1 answer

Solving inaccesible variable inside jquery .bind() anonymous function using react lifecycle

I need to have access to the jqconsole variable outside of the anonymously bound function. How do i instantiate it outside of the JQuery habitat? If possible, i would just save it globally or to my state. I did not manage to get it to run this way. …
Divide by Zero
  • 1,343
  • 1
  • 14
  • 37