expo / router

[ARCHIVE]: Expo Router has moved to expo/expo -- The File-based router for universal React Native apps
https://docs.expo.dev/routing/introduction/
1.36k stars 113 forks source link

Native logs are swallowed after first full render #234

Closed SleeplessByte closed 1 year ago

SleeplessByte commented 1 year ago

Summary

Using the demo app as a basis, if you run this on Android, logs are not shown after the first few seconds.

Sign in, create a note, sign out

Expected:

 LOG  (app)  /              # before checking auth state
 LOG  (auth) /sign-in       # after auth state was checked
 LOG  (app)  /              # after sign in was pressed
 LOG  (app)  /compose       # after create note was pressed
 LOG  (app)  /              # after note was created
 LOG  (app)  /note/abcdefg  # after note was clicked
 LOG  (app)  /              # after back
 LOG  (auth) /sign-in       # after sign out

Actual:

 LOG  (app)  /              # before checking auth state
 LOG  (app)  /              # before checking auth state

After this, no logs appear.

Minimal reproducible example

https://github.com/expo/router/tree/main/apps/demo

Add to context/auth.tsx at line 14.

const path = usePathname();
console.log(rootSegment, path);

image

On web it logs as expected:

(app)  /                # before checking auth state
(app)  /                # before checking auth state
(auth) /sign-in         # after auth state was checked
(app)  /                # after sign in was pressed
(app)  /compose         # after create note was pressed
(app)  /                # after note was created
(app)  /note/qp3vdjnhy  # after note was clicked
(app)  /                # after back
(app)  /                # after sign out (set state)
(auth) /sign-in         # after sign out (replace route)
EvanBacon commented 1 year ago

Expo Router has no overlap with how logs are sent from the runtime or received by Expo CLI. The behavior you're observing is the result of different rendering policies across platforms. Some platforms are rendering the component more than others which is expected behavior at the moment.

SleeplessByte commented 1 year ago

Are you saying it's expected that logs are swallowed completely (not showing up)?

I would like to re-open this issue in the appropriate place. Would that be expo-cli? Please note that the problem is not the amount of logs or duplicates. It's that this example project generates NO logs after the first one, when running on Android.

brentvatne commented 1 year ago

https://user-images.githubusercontent.com/90494/216785177-ba9a2639-910b-424b-8df6-ae687aaed477.mov

i've tried to reproduce this but was unable to. any suggestions @SleeplessByte?

SleeplessByte commented 1 year ago

My first guess would be windows, and this being a cli issue, and not, like Evan said, being a router issue.

I'm on windows 11, cmd.exe terminal (since we no longer have the metro ui).

My second guess would be a difference between real devices and emulators. I was using a real device. I can test this if you like.

Third guess would be not OS, but terminal related. I have a machine at the office with 6 windows terminals, some of which are more unix-compatible than others. @brentvatne for this I can do a test against all of them next week if you like.

Fourth guess would normally be some local environment or installation difference, but this was a brand new machine (as in, one of the first things I did when I got it was trying out expo router because I am very excited to have our company use it). So whilst that still is possible, it is incredibly improbable for this particular issue.