You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is props just the name of an object like cat, but just a name that React chooses to use? What is more common in React apps? To see props.name or to just destructure the object so you don't even see props. Is there any reason why I need to use props in my react app? Or could I just get the data (from a CMS graphql query for instance) and put it into an object with any name (like cat) or just skip the naming part and destructure it directly? Or is there a good reason to use props with React?
Need more clarity on the React concept of props. I do think it's good to introduce here because that is what you're gonna see a ton of when you start googling code examples, but some more explanation is needed.
The text was updated successfully, but these errors were encountered:
Is props just the name of an object like cat, but just a name that React chooses to use?
yes
What is more common in React apps? To see props.name or to just destructure the object so you don't even see props.
I like destructuring because it's cleaner.
Is there any reason why I need to use props in my react app?
No, not if you destructure your objects correctly.
Or could I just get the data (from a CMS graphql query for instance) and put it into an object with any name (like cat) or just skip the naming part and destructure it directly? Or is there a good reason to use props with React?
Yes, this is exactly the way. I'll add this to the opinion section. I suppose that's a personal preference thing. Would be cool to somehow incorporate a poll or analysis react code to see if props is used more or less. The argument could be made that it gives a code reader an easy way to grasp that props.name is coming from a parent component. On the other side, it's cleaner when you're just passing name into the component with destructuring, but you don't have that quick cue of props to indicate the data is "passed in via props". So not using props might make a code reader think more, but if your components are small and not too many lines of code (and thus easier to think about), then not using props would be appropriate.
Is props just the name of an object like cat, but just a name that React chooses to use? What is more common in React apps? To see props.name or to just destructure the object so you don't even see props. Is there any reason why I need to use props in my react app? Or could I just get the data (from a CMS graphql query for instance) and put it into an object with any name (like cat) or just skip the naming part and destructure it directly? Or is there a good reason to use props with React?
Need more clarity on the React concept of props. I do think it's good to introduce here because that is what you're gonna see a ton of when you start googling code examples, but some more explanation is needed.
The text was updated successfully, but these errors were encountered: