React-redux-firebase: Server Side Rendering with Firestore

Created on 4 May 2018  路  5Comments  路  Source: prescottprue/react-redux-firebase

Do you want to request a feature or report a bug?

At the moment i don't know if promiseEvents is just not implemented for firestore (feature) or if its just broken (bug).

What is the current behavior?

I use, like in the docs written, the promiseEvents function to load data from my firestore database, after creating the store, but unfortunately it doesn't work as expected. The response of the Promise is just undefined

This is my store config:

// ...
firebase.initializeApp(firebaseConfig);

const firestore = firebase.firestore();

firestore.settings(firestoreConfig);

const createStoreWithFirebase = composeEnhancers(
  reactReduxFirebase(firebase, reactReduxFirebaseConfig),
  reduxFirestore(firebase)
)(createStore);

// Add firebase to reducers
const rootReducer = combineReducers({
  ...reducer,
  firebase: firebaseReducer,
  firestore: firestoreReducer
});

export const store = createStoreWithFirebase(rootReducer, preloadedState);

store.firebase // getFirebase can also be used
  .promiseEvents([
    { path: 'todos' } // todos collection in firestore
  ])
  .then((data) => {
    console.log('data is loaded into redux store');
    console.log(data)
  });
// ...

The response in the browser console is:

- data is loaded into redux store
- [undefined]

What is the expected behavior?
I expect that the data is loaded before the rendering starts (on the server-side) and that it's loaded in the state so the components know there props and everything will be rendered.

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

  • Browser: latest Chrome
  • Node: v10.0.0
  • npm: 5.6.0
  • react-redux-firebase: 2.0.6
  • redux-firestore: 0.4.3

Did this work in previous versions or setups?

Nope

<3 Btw.. awesome project, beside the server-side-rendering everything works perfectly!

All 5 comments

@michaelzoidl Hadn't really build/tested promiseEvents for Firestore, but I look into it. Thanks for reporting!

Glad to hear everything else is working perfectly for you!

@prescottprue thanks :)

For your information, when i call a firestore function e.g. get it works also on the server-side and since it's a promise i can handle it exactly like the promiseEvents.

Example:

await store.firestore.get('todos');

Should we close this issue then? Maybe add this to the documentation (or some kind of note)

Oh, great to know. Yeah, adding it to the docs is the right call, then we can close this issue.

Open to a PR if you get to it, if not I will try to get to it sometime this weekend.

@prescottprue sorry totally forgot this issue.

馃槄Honestly, i think it makes more sense that you catch up this since i never updated the docs, this is just a tidy thing it feels like you will be way faster than me.

Docs updated, thanks for reporting.

Was this page helpful?
0 / 5 - 0 ratings