Skip to content

Server Side Rendering with Firestore #456

Closed
@michaelzoidl

Description

@michaelzoidl

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions