Unverified Commit 641976a4 authored by David Janda's avatar David Janda Committed by GitHub

Replace getInitialProps with getServerSideProps (#11586)

parent 97a6b64f
...@@ -5,16 +5,21 @@ import 'firebase/firestore' ...@@ -5,16 +5,21 @@ import 'firebase/firestore'
import 'isomorphic-unfetch' import 'isomorphic-unfetch'
import clientCredentials from '../credentials/client' import clientCredentials from '../credentials/client'
export default class Index extends Component { export async function getServerSideProps({ req, query }) {
static async getInitialProps({ req, query }) {
const user = req && req.session ? req.session.decodedToken : null const user = req && req.session ? req.session.decodedToken : null
// don't fetch anything from firebase if the user is not found // don't fetch anything from firebase if the user is not found
// const snap = user && await req.firebaseServer.database().ref('messages').once('value') // const snap = user && await req.firebaseServer.database().ref('messages').once('value')
// const messages = snap && snap.val() // const messages = snap && snap.val()
const messages = null const messages = null
return { user, messages } return {
props: {
user,
messages,
},
} }
}
export default class Index extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment