0
votes

In React, inside a functional component is it a good practice to use a props array to filter it and assign to a const and use that without setting the const value to a useState. In this case i don't have any state updation inside the component.

1
I'm not sure what you're asking.Dave Newton
can you add your code alsoAravinda Meewalaarachchi
The problem with this approach is that you are not triggering a rerender, we use states to trigger a rerender on the components, either a change in the component state or a change in the props.Menawer
The component gets props from parent and there is no state changes specific to the child. For example there is no events and just need to render the filtered prop in the UI.ash

1 Answers

0
votes

Yes that is perfectly fine and means you do not have to manage your state on a component update. For example, if a filter parameter would change.

However, just realize you are filtering on each render. Compared to a single time if you would store the variable in state as you mentioned.