Questions tagged [react-lifecycle]
313 questions
0
votes
1 answer
Problem accessing data of an array created from the state in Reactjs
I have an array of country codes and I need to have the name.
I am trying to access the countries data from the state (axios call) and from there filter by country code, and from that new array, extract the common name of the country.
(I am using…

ihatepineapple
- 55
- 1
- 8
0
votes
1 answer
Lifecycle issue on axios call to an external API
I am trying to make an axios call on a react functional component, but the lifecycle is giving me a headache, as it continuously returns "can not read property of undefined".
I tried using conditional rendering as well as await/async function, but…

ihatepineapple
- 55
- 1
- 8
0
votes
1 answer
Render react class component on route params change
I used to work with functional components only so I am having a problem with class components life cycles.
I need to rerender the class when the params id changes. I was able to change the params id with history.push(home/items/${id}) but as the…

Davrick
- 301
- 1
- 4
- 13
0
votes
2 answers
Handling response status in React useEffect hook - lifecycle issue?
I'm currently rendering some data by fetching from API within the useEffect hook.
I have a searchValue variable which holds the value the user inputs on the home page search field. This is passed down to this component.
I have set searchValue in the…

Joe
- 918
- 1
- 8
- 17
0
votes
1 answer
How can we do deep comparison of "this.props" and "nextProps" in "shouldComponentUpdate"?
So far, what I'm aware is, if the props (current and next) and stringified and then compared, it might provide some result. But, I'm not sure if that works correctly for props which are holding functions. If there is any other possible way to do so,…

Uma Maheswar
- 11
- 2
0
votes
0 answers
My component does not re-render on store data changes
Redux store changes but component does not get rendered ,when user login and we are returned back to product component Redux store does not update component and its props
class Product extends React.Component {
onClickAdd(){
if(!user) {
…

shabaz-tech
- 9
- 3
0
votes
0 answers
unable to get the value of input field using this.ref.current.value in react
I am trying to get the value of input field in my form using ref, when the form is submitted, handletagsubmit function is called where I am trying to fetch the value of the input field using this.tagInputRef.current.value, but when I console log…

Chirag Lalwani
- 41
- 7
0
votes
3 answers
Function variable value resetting after calling this.setState
I am relatively new to the JavaScript world, i am learning react and have encountered a weird issue
see this code
addIngredientHandler = (type) => {
let oldCount = this.state.ingredients[type];
let copyState =…

Shantanu Bedajna
- 559
- 10
- 34
0
votes
0 answers
Lifecycle of useState hook in React.js
I have the following synchronism problem. Given that I know that the React useState hook is asynchronous, I run into the following: I'm downloading some images from Amazon S3, I manage to save it correctly in my hook: defaultSelfiePicture and…

Raul
- 659
- 1
- 6
- 11
0
votes
1 answer
How to use getDerivedStateFromProps in an update state situation?
I'm confused about the refactoring of my code.
My Component works like this ==> I set the incoming props from the parent component to the child component's state. Then I can do the update state operations in the component.
This is my…

ffcabbar
- 351
- 1
- 3
- 18
0
votes
2 answers
How to re-render a list after deleting an element
I am trying to write a delete method in order to delete an element from a list, first of all I am not being able to write it in a setState function so I have it as a direct function call, How can I manage to signal a re-render after the direct…

Walter
- 19
- 1
- 6
0
votes
2 answers
Which strategy to use when displaying a value on the screen that comes from a useState hook of React and not re render unless under an action?
I have a report generated by three parameters. An user and 2 range date fields.
e.g:
When all fields are filled, the report can be generated by Gerar button.
e.g when generated:
The problem i don't know how to handle happens now. When a value of…

RAFAEL DA SILVA
- 99
- 2
- 11
0
votes
0 answers
Remove Event Listener from React Hooks Element
I have a question regarding Event Listeners inside React Components. For window events I always use the return function inside the useEffect, but for the project I'm currently working on, I introduced an event listener to the component.
For window…

Victor Thadeu
- 89
- 1
- 7
0
votes
1 answer
The issue of React Lifecycle in a Functional Component (Data undefined in the child component)
I ran into a problem when I try to call backend api from a parent component the call result is always null in the child component.
Here is my implementation:
The parent component:
const Parent = () => {
const { loadFiData, fiData, year } =…

Brahim Oui
- 29
- 2
- 8
0
votes
1 answer
Array.includes returning conflicting results on react component load
I have a Profile component that, on load, calls a Django server to grab an array of IDs representing bookmarked profiles. If the bookmarks array contains the ID of the profile that the user is on (i.e. if the user is on /profile/1 and if [1, 4,…

crevulus
- 1,658
- 12
- 42