Skip to content

Commit

Permalink
chore(components): remove lifecycle warning from using componentWillM…
Browse files Browse the repository at this point in the history
…ount (#969)
  • Loading branch information
lidaof authored Aug 12, 2020
1 parent e6bc218 commit b71bfc9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-redux-firebase",
"version": "2.5.0",
"version": "2.5.1",
"description": "Redux integration for Firebase. Comes with a Higher Order Components for use with React.",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
6 changes: 4 additions & 2 deletions src/firebaseConnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { v3ErrorMessage } from './constants'
*/
export const createFirebaseConnect = (storeKey = 'store') => (
dataOrFn = []
) => WrappedComponent => {
) => (WrappedComponent) => {
class FirebaseConnect extends Component {
static displayName = `FirebaseConnect(${getDisplayName(WrappedComponent)})`
static wrappedComponent = WrappedComponent
Expand All @@ -39,7 +39,9 @@ export const createFirebaseConnect = (storeKey = 'store') => (
prevData = null
store = this.context[storeKey]

componentWillMount() {
/* eslint-disable camelcase */
UNSAFE_componentWillMount() {
/* eslint-enable camelcase */
// Throw if using with react-redux@^6
if (!this.context || !this.context[storeKey]) {
// Use react-redux-firebase@^3 for react-redux@^6 support. More info available in the migration guide: http://bit.ly/2SRNdiO'
Expand Down
13 changes: 9 additions & 4 deletions src/firestoreConnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { v3ErrorMessage } from './constants'
*/
export const createFirestoreConnect = (storeKey = 'store') => (
dataOrFn = []
) => WrappedComponent => {
) => (WrappedComponent) => {
class FirestoreConnect extends Component {
static wrappedComponent = WrappedComponent
static displayName = wrapDisplayName(WrappedComponent, 'FirestoreConnect')
Expand All @@ -40,7 +40,9 @@ export const createFirestoreConnect = (storeKey = 'store') => (
return !!this.store.firestore
}

componentWillMount() {
/* eslint-disable camelcase */
UNSAFE_componentWillMount() {
/* eslint-enable camelcase */
// Throw if using with react-redux@^6
if (!this.context || !this.context[storeKey]) {
// Use react-redux-firebase@^3 for react-redux@^6 support. More info available in the migration guide: http://bit.ly/2SRNdiO'
Expand Down Expand Up @@ -86,8 +88,11 @@ export const createFirestoreConnect = (storeKey = 'store') => (

getChanges(data = [], prevData = []) {
const result = {}
result.added = filter(data, d => !some(prevData, p => isEqual(d, p)))
result.removed = filter(prevData, p => !some(data, d => isEqual(p, d)))
result.added = filter(data, (d) => !some(prevData, (p) => isEqual(d, p)))
result.removed = filter(
prevData,
(p) => !some(data, (d) => isEqual(p, d))
)
return result
}

Expand Down

0 comments on commit b71bfc9

Please sign in to comment.