-
-
Notifications
You must be signed in to change notification settings - Fork 555
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
Fix issue with reserved prop names inside firebaseConnect #613
Conversation
Prior to this commit firbaseConnect used the prop 'firebase' to receive the firebase app reference. This meant that if another prop called firebase (for instance, from the default reducer configuration) was supplied to a firebaseConnect wrapped component it would clobber the variable. This would result in either unexpected data in state, or alternatively the inability for developers to nest firebaseConnect wrapped components. This commit renames the internal reference, and also checks to see if reserved words are passed through and throws an error with a useful message that can help developers debug if they accedentally provide one of these reserved props.
Hrmm. Just got off a plane, will look at cleaning this up tomorrow 👍 |
Codecov Report
@@ Coverage Diff @@
## next #613 +/- ##
========================================
+ Coverage 78.4% 78.61% +0.2%
========================================
Files 26 26
Lines 917 926 +9
Branches 165 166 +1
========================================
+ Hits 719 728 +9
Misses 198 198 |
Fixed @prescottprue, have a look and let me know if you want anything changed and / or a different approach entirely. Tried to make it resilient to this class of errors in the future. Unfortunately we can't test for what the developer is going to pass into a connected component in build (in fact in some cases the developer might not even know off the top of their head), but we can prevent clashes during execution and raise a helpful error, plus make the internals obscure enough that they wont get hit. |
Really awesome to see the fix and such a comprehensive PR/explanation around it, thanks! I'll merge after testing it a bit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small typo
Great work on this @theashguy and @iamthefox , and thanks a ton for contribution. It is awesome to see the full feature, the tests, and sticking with the PR to solve merge conflicts. |
* fix(firebaseConnect): rename internal props and throw for name collisions - #613 - @theashguy + @iamthefox * fix(HOCs): missing props (firebase + dispatch) added - #606 * feat(typings): major upgrade to typescript definitions (including types from `@firebase`) - #627 - @rscotten
This is causing some issues with the usage of the Going to keep in the throwing for passed reserved prop names, but add back the Really it is better to pass sections of the state from the reducer instead of the whole state anyway. That said, I do think there needs to be better naming conventions. |
fix(tests): add case to firebaseConnect to confirm firebase and dispatch props
Description
Prior to this commit firebaseConnect used the prop 'firebase' to receive the firebase app reference. This meant that if another prop called firebase (for instance, from the default reducer configuration) was supplied to a firebaseConnect wrapped component it would clobber the variable. This would result in either unexpected data in the store, or alternatively the inability for developers to nest firebaseConnect wrapped components.
An example case by @iamthefox has been uploaded here:
https://github.com/iamthefox/react-redux-firebase/blob/next-nested-issues/examples/complete/nested-issue/src/Home.js#L30
This commit renames the internal reference, and also checks to see if reserved words are passed through and throws an error with a useful message that can help developers debug if they accidentally provide one of these reserved props.
Note: This same issue could exist for firestore as well, however I don't have any examples to test with.
Check List
If not relevant to pull request, check off as complete
Relevant Issues
Raised in gitter, example provided in description.