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
[Question] here is a breaking change with 7.25.1 or 7.25.0 #3060
Comments
7.24.0 is ok |
This isn’t a breaking change, it’s a bug fix. Those errors should have been reported the whole time. |
But you can see, I am not use bind in these files. |
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md#no-bind-or-arrow-functions-in-jsx-props-reactjsx-no-bind says "No .bind() or Arrow Functions in JSX Props". |
ok yep, that looks like a bug, thanks for the link :-) cc @p7g |
To clarify, is there a bug in the implementation or this behaviour should just not be enabled by default? |
@p7g there's a bug in the implementation. @SoloJiang we need the link to the files to remain, otherwise we won't be able to fix it. can you restore it? (it looks like you deleted it) |
This is impacting us as well. For the usage we are getting flagged with, the message is confusing or misleading. And I wonder if the rule is too strict or not. We are not using
The error message is "JSX props should not use functions". Well functions are completely normal in JSX props for handlers and the rule page title specifically calls out bind and arrow functions. Going through the rule doc clarifies that what it really is complaining about is that inline, arrow, and local functions have potential performance implications. But in our experience, there are many times when generating a small function each render results in a tiny perf difference not generally noticeable for lesser used components and flows. Wrapping this function in a If it's decided that local functions and arrow functions should always be wrapped in a |
@redbugz the modern approach in SFCs is to use This rule should always have warned on these, and they're always preferable to avoid, so if you want to ignore this best practice, the proper thing to do is disable the rule. I am always happy to improve error messages, and would welcome a PR that did so. |
Apparently this was a fairly common practice in our organization and our config was set to error on this rule, so suddenly many builds are broken. I understand your position and reasoning and now that it's clear how this rule will be applied, we can move forward. To get things moving again, we will switch to warning or pin back to 7.24.0, and then work to migrate the code forward. Thanks for quickly explaining your position. |
Note that we could revert it by default and put it behind an option - and if enough people report difficulty, we may. However, it's always nicer when we can roll forward and expose new users to the best experience by default. |
You can sort of work around this for now by enabling
although this will end up also allowing inline function expressions. I think it's good that this workaround has been caught now. My team has been abusing this for too long 😄
You have my support. |
To clarify, what is the bug? Shouldn't these cases error after #3048 if |
I'm getting just a little bit of pushback on this rule. I'm curious what you think about this post: https://kentcdodds.com/blog/usememo-and-usecallback Some say that using We'll adapt to whatever is decided. I was just curious if the above line of thinking is outdated, or has some merits but the lint rule will continue to encourage always using |
I don't agree with that post, and prefer the rationale in https://attardi.org/why-we-memo-all-the-things/ In other words, yes, if you are fortunate enough to find one of the highly unlikely cases where it's detrimental, use a comment. |
This linting error was introduced when `eslint-plugin-react` fixed a bug in 7.25.0 Regarding the fix, we're using useCallback to wrap function passed as props. "The modern approach in SFCs is to use useCallback on all function props" - @ljharb, of TC39 jsx-eslint/eslint-plugin-react#3060 (comment)
This linting error was introduced when `eslint-plugin-react` fixed a bug in 7.25.0 Regarding the fix, we're using useCallback to wrap function passed as props. "The modern approach in SFCs is to use useCallback on all function props" - @ljharb, of TC39 jsx-eslint/eslint-plugin-react#3060 (comment)
This linting error was introduced when `eslint-plugin-react` fixed a bug in 7.25.0 Regarding the fix, we're using useCallback to wrap function passed as props. "The modern approach in SFCs is to use useCallback on all function props" - @ljharb, of TC39 jsx-eslint/eslint-plugin-react#3060 (comment)
This seems answered. |
https://github.com/alibaba/rax/runs/3458857417
The text was updated successfully, but these errors were encountered: