componentWillRecieveProps warning
Can you please implement a warning for when a component tries to implement the componentWillRecieveProps method instead of the componentWillReceiveProps method?
Almost every React person I know has been bitten by this and it always take 30 minutes of debugging to find and then you feel like a dummy the rest of the day.
Sure, we have another for componentShouldUpdate (which is the common "typo" of shouldComponentUpdate). Would it be cool if we just said "I BEFORE E EXCEPT AFTER C, and also other times because English is silly and inconsistent."?
I'd like to take a stab at this.
@zpao
Would adding a noop fn that returns the warning wrapped in a __DEV__ block in https://github.com/facebook/react/blob/master/src/isomorphic/classic/class/ReactClass.js make sense?
Or is there a common place for handling errors for invalid methods / prop names?
Tests required for this?
I think it probably belongs alongside the warning for componentShouldUpdate, which should already be dev only.
This looks like the job for a linter not the React library?
@raybooysen, Ideally, but I don't think many linters can check for undefined variables across imports, and some of the react userbase isn't using one. Whether we should support that use-case or not is a valid question though.
Closed via #4045.
Yes, ideally this is a part of lint. I think it could be cool if https://github.com/yannickcr/eslint-plugin-react has a rule for it - feel free to suggest it to @yannickcr (and/or write it :wink:)
@zpao I was not very comfortable with typos detection (see my response here) but if React start to "officially" warn about some typos I think we can try to mimic it's behavior (like we did for no-unknonw-property) to warn the developer before code execution.
@yannickcr Your call. We try to keep it pretty minimal in core, this 1 added here after 2 years, componentShouldUpdate added a lot earlier, incorrectly-cased DOM props a while ago. There's another for mistyped event handlers. We'll adjust with more or less later I'm sure. I'm currently on a "machines should fix all my problems" kick so I like more linting. If you don't add it that's totally your call - I'm appreciative of the rules you do have :) If somebody wants to add their own rules, eslint makes this super easy so they can write their own.