-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(context): Switch to new React context API (#40)
Change to using the new React context API that was released with React 16.3 BREAKING CHANGE: This requires you to use React >= 16.3. Make sure to upgrade your `react` and `react-dom` dependencies to be _at least_ 16.3 or greater!
- Loading branch information
1 parent
9b00fdf
commit 5f4d581
Showing
22 changed files
with
681 additions
and
499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
import { Component } from 'react'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { FirestoreContext } from './FirestoreProvider'; | ||
|
||
class Firestore extends Component { | ||
static propTypes = { | ||
render: PropTypes.func.isRequired, | ||
}; | ||
const Firestore = ({ render }) => ( | ||
<FirestoreContext.Consumer> | ||
{({ firestoreDatabase }) => render({ firestore: firestoreDatabase })} | ||
</FirestoreContext.Consumer> | ||
); | ||
|
||
static contextTypes = { | ||
firestoreDatabase: PropTypes.object.isRequired, | ||
}; | ||
|
||
render() { | ||
const { firestoreDatabase } = this.context; | ||
const { render } = this.props; | ||
|
||
return render({ firestore: firestoreDatabase }); | ||
} | ||
} | ||
Firestore.propTypes = { | ||
render: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default Firestore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.