async-labs / saas

Build your own SaaS business with SaaS boilerplate. Productive stack: React, Material-UI, Next, MobX, WebSockets, Express, Node, Mongoose, MongoDB. Written with TypeScript.
https://saas-app.async-await.com
MIT License
4.11k stars 683 forks source link

chapter 7 currentUser is undefined #126

Closed andrewshrout closed 4 years ago

andrewshrout commented 4 years ago

Following along the tutorial, but when I go to yarn dev first time it calls for it, I get this error when trying to visit the page.

I've created store/index.ts, and user.ts exactly how the tutorial says. I've altered your-settings, and withAuth. Moved updateProfileApiMethod, and gone over everything twice. Can't figure out why it won't render. If the default user is null, shouldn't it be able to render?

TypeError: Cannot read property 'currentUser' of undefined
WithAuth.render
./lib/withAuth.tsx:59
  56 | 
  57 |    public render() {
  58 |      const { store } = this.props;
> 59 |      const user = store.currentUser;
     | ^  60 | 
  61 |      if (loginRequired && !logoutRequired && !user) {
  62 |        return null;

https://github.com/andrewshrout/saas-book-course/tree/master/book/7-begin

andrewshrout commented 4 years ago

Wasn't passing store={store} in my _app component.

tima101 commented 4 years ago

@andrewshrout Do we need to edit anything in the book's content?