rooteco / tweetscape-streams

3 stars 3 forks source link

use useMatches() to get user object loaded in routes/streams.tsx #15

Closed ntorba closed 2 years ago

ntorba commented 2 years ago

this fixes the lack of the login with twitter button disappearing in the body after redirecting

ntorba commented 2 years ago

@andrepology this was the refresh issue I thought you told me about. Now, after you login with twitter and get redirected back to the app, it shows the form to create a new stream in the body, instead of the Login with Twitter button still being there until you refresh the page.

I fixed this with remix useMatches() hook

Here is the output of the matches (which i used to grab the user in routes/streams/index.tsx)

MATCHES
[
  {
    id: 'root',
    pathname: '/',
    params: {},
    data: undefined,
    handle: undefined
  },
  {
    id: 'routes/streams',
    pathname: '/streams',
    params: {},
    data: { streams: [Array], user: [Object] },
    handle: undefined
  },
  {
    id: 'routes/streams/index',
    pathname: '/streams/',
    params: {},
    data: null,
    handle: undefined
  }
]