-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
void-dom-elements-no-children throws a TypeError when installed from the current master branch. #1101
Comments
It would absolutely be helpful to gist the source file it crashes on, thanks! |
Sure thing! Went ahead and dumped the JSX, my |
@phyllisstein I assume https://gist.github.com/phyllisstein/04036a187aa4c2d4195a67cefb4170cb#file-button-jsx-L112-L119 is the problem - if you remove https://gist.github.com/phyllisstein/04036a187aa4c2d4195a67cefb4170cb#file-button-jsx-L113 does the problem go away? (if not that, this?) |
So I did a little ham-handed investigation and started deleting lines blindly. Turns out it's the |
Interesting - probably because it's an arrow function class property. If instead (which would be much more performant) it was a true instance method, and you did Thanks though, this should be very helpful to fix the bug. |
Why exactly? You still create a bound function in constructor, that's roughly what arrow function property compiles to |
Yes, in the constructor once, instead of thousands of times once per render. |
I thought if the arrow function is a class property, it is also only computed once? class Foo extends Component {
myArrowFunc = () => { ... }
} Din't think @Hypnosphi is talking about arrow functions within |
Yes, that's true. But at that point the meat of the function isn't in an optimized prototype method, its newly created on every render. Constructor-bound prototype methods are the best approach. |
I didn't know that, thanks! Fixes an incorrect belief of mine. |
class Foo {
myArrowFunc = () => { ... }
} compiles to class Foo {
constructor() {
this.myArrowFunc = () => { ... };
}
} Excuse me, but I don't see any rendering here. Did you mean "on every constructor call" instead? Then it shouldn't occur too often in a typical react app. |
@Hypnosphi yes, you're right that your example isn't about the render path. However, #1101 (comment) still applies. |
Hey there! I hate to be a bother, but I just tried installing this plugin from GitHub, overeager to see if JSX indentation had been improved, and ran into a little trouble linting one of my source files. The
void-dom-elements-no-children
rule is throwing aTypeError
on line 107:Logging
node.arguments
shows that it's an empty array just before the crash, but honest I don't know nearly enough about your lovely linter's deep magic to say any more than that. Please let me know if it'd be helpful to Gist the source file, though, or if I can furnish any other information I've got. Disabling the rule in my ESLint config stops the crash for now.The text was updated successfully, but these errors were encountered: