Component Props = Function arguments #10884
stargazer33
started this conversation in
Ideas
Replies: 2 comments 1 reply
-
An interesting thing to consider here is that a surprising amount of people expect Astro components to work like React JSX components, where they can call them as a function. If we say "Props are like function arguments" that might lead to more confusion among those people. |
Beta Was this translation helpful? Give feedback.
1 reply
-
This can be explained roughly this way: for people with background in procedural languages ( C, Python, Java) - props are like function arguments |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I almost broke my head reading this section:
https://docs.astro.build/en/basics/astro-components/#component-props
What are actually these "props" ?
And then I realized a simple thing:
Defining props in .astro file -> we defining arguments.
When we render the component with some props: we are not "passing these props as attributes". We passing actual arguments.
OK, sometimes instead of "arguments" they say "parameters".
"Props" is quite a strange and unusual name. Anyway just explain in documentation:
"these props are actually component arguments, just like function arguments".
This will make documentation much more clear!
Beta Was this translation helpful? Give feedback.
All reactions