Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing Data Between Components: Fix what I think is an Error #27975

Open
3 tasks done
reda777 opened this issue May 15, 2024 · 3 comments · May be fixed by #27980
Open
3 tasks done

Passing Data Between Components: Fix what I think is an Error #27975

reda777 opened this issue May 15, 2024 · 3 comments · May be fixed by #27980
Assignees

Comments

@reda777
Copy link

reda777 commented May 15, 2024

Checks

Describe your suggestion

There is probably a Typo or a wrong statement that needs to be corrected.

You can rename the function to whatever you like when passing through as props, the prop name and value do not need to be the same. We could just as easily write superCoolFunction={handleButtonClick}.

I don't know the reason why this was mentioned. The prop name and value were never the same in this lesson, and if you were to change the prop name in this case, handleClick to superCoolFunction you'll have to change the prop name in the Button function.

Path

Node / JS

Lesson Url

https://www.theodinproject.com/lessons/node-path-react-new-passing-data-between-components

(Optional) Discord Name

No response

(Optional) Additional Comments

No response

@MaoShizhong
Copy link
Contributor

Thanks for opening this issue @reda777. That bullet in the lesson is correct - it's just reinforcing the fact that the prop name can be anything and doesn't have to match the name of the function you're passing in. That being said, I can definitely see where the confusion is coming from and that bullet can be worded more clearly. e.g.

The prop name does not have to match the name of the function passed in. You can see we've called the prop handleClick instead of handleButtonClick, and we could also have called the prop superCoolFunction if we wanted.

Would a change like this make the point clearer?

@reda777
Copy link
Author

reda777 commented May 15, 2024

Yeah I was confused reading it. The note could be useful if the snippet code included something like handleClick={handleClick}, but I don't think it's necessary to state if the code already demonstrates that point. If you still want to keep the note, a clearer version like the one you wrote should be fine I think. Thanks for taking the time to reply.

@MaoShizhong
Copy link
Contributor

Yeah, I don't think we need to be that explicit with a same-name example. I agree the current wording does make it sound like a brand new point rather than a reinforcing of what's already been shown. I'll assign this to you 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants