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

function-component-definition should only test PascalCase identifiers #2778

Closed
wmertens opened this issue Aug 31, 2020 · 8 comments
Closed

Comments

@wmertens
Copy link

function meep(props) {
  return <Meep />
}

Should not be changed by function-component-definition.

@ljharb
Copy link
Member

ljharb commented Aug 31, 2020

While this is true, why would you have a function like this in the first place, that takes props and returns jsx and isn't named PascalCased?

@wmertens
Copy link
Author

This would be a render function, which is passed to a component and gets called as part of the render phase

@ljharb
Copy link
Member

ljharb commented Aug 31, 2020

Render functions don't take props.

@wmertens
Copy link
Author

They might, and in #2771 the examples actually do

@ljharb
Copy link
Member

ljharb commented Aug 31, 2020

They take arguments - props are only taken by elements/components.

@wmertens
Copy link
Author

...ok, but they are indistinguishable in code?

function Foo({bar}) { return <span>{bar}</span/> }
function renderFoo({bar}) { return <span>{bar}</span/> }

@ljharb
Copy link
Member

ljharb commented Aug 31, 2020

Nope :-) but conceptually they're distinct, and you named your argument "props" which is a signal that it's a component, as is, taking a single destructured object argument - render props usually take multiple flat arguments.

@ljharb
Copy link
Member

ljharb commented Feb 20, 2022

This seems answered; if not, we can reopen.

@ljharb ljharb closed this as completed Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants