Skip to content
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

Updated with-firebase-authentication to use getServerSideProps #11586

Merged
merged 1 commit into from
Apr 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions examples/with-firebase-authentication/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ import 'firebase/firestore'
import 'isomorphic-unfetch'
import clientCredentials from '../credentials/client'

export default class Index extends Component {
static async getInitialProps({ req, query }) {
const user = req && req.session ? req.session.decodedToken : null
// don't fetch anything from firebase if the user is not found
// const snap = user && await req.firebaseServer.database().ref('messages').once('value')
// const messages = snap && snap.val()
const messages = null
return { user, messages }
export async function getServerSideProps({ req, query }) {
const user = req && req.session ? req.session.decodedToken : null
// don't fetch anything from firebase if the user is not found
// const snap = user && await req.firebaseServer.database().ref('messages').once('value')
// const messages = snap && snap.val()
const messages = null
return {
props: {
user,
messages,
},
}
}

export default class Index extends Component {
constructor(props) {
super(props)
this.state = {
Expand Down