This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
Good practice for react-this-binding-issue #676
Labels
Domain: Documentation
Rules or repository tasks related to how to document code.
Milestone
(Sorry this is not a bug report or feature request, but I figured it would be nice to have this listed somewhere on the repo)
Up until v6.0.0, we were gently riding on a bug of the
react-this-binding-issue
rule that was not seeing some violation. Imagine the following, minimal (as much as I could) example:Prior to v6, TSLint was okay with that, but after the upgrade:
So, yeah, I am creating a new function each time.
What solution do you recommend for this type of violations (that we have across our codebase)?
As far as I can tell, I could
onChange
function to goonChange={onChange(name)}
to trump the linter, but the underlying issue of creating a function each time would still be there, and that would make for a sillier API for whoever consumes this.this.onChange(checked) { return name => this.props.onChange(name, checked); }
and useonChange={this.onChange}
, which doesn't force the API to change, but I believe still creates plenty anonymous functions, and prevents us to use nice and small SFCs.tslint:disable
, but that's just sad.memoizee
+curry
and useonChange={memoize(curry)(onChange, name)}
.Am I missing something nicer and easier to use that would make the linter happy?
The text was updated successfully, but these errors were encountered: