added docker stuff and updated next.js to ^7.0.0

This commit is contained in:
JJ Kasper
2018-09-21 15:17:55 -05:00
parent 2230f72160
commit 56f9ee318f
62 changed files with 16686 additions and 11907 deletions

View File

@@ -27,20 +27,34 @@ export default ComposedComponent => {
id: null,
doc: {},
}
static async getInitialProps({ query, req }) {
return await getDoc(query.id, req)
}
static getDerivedStateFromProps(nextProps, state) {
static getDerivedStateFromProps(nextProps, prevState) {
const { found, id, doc } = nextProps
if (state.found !== found) return { found, id, doc }
if (prevState.found !== found && !prevState.didInit) {
return { found, id, doc, didInit: true }
}
return null
}
async componentDidUpdate(prevProps) {
updateDoc = async id => {
this.setState(await getDoc(id))
}
componentDidMount() {
this.updateDoc(this.props.id)
}
componentDidUpdate(prevProps) {
const { user, found, id } = this.props
if (prevProps.user.email === user.email || found) return
if (!user.email) return
this.setState(await getDoc(id))
this.updateDoc(id)
}
render() {
return <ComposedComponent {...this.state} />
}