Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Unmatched route (Page not found) - warn when missing default export #576

Open
Albert-Gao opened this issue May 16, 2023 · 8 comments

Comments

@Albert-Gao
Copy link

Albert-Gao commented May 16, 2023

Which package manager are you using? (Yarn is recommended)

npm

Summary

here is the structre

---Stack
------(main-tabs)
---------tab1
------clip
---------[clipId]

You can see that (main-tabs) and clip sits at the same level

when I go to [clipId] from tab1, I got that error

Minimal reproducible example

Here is the demo (expo-router: 1.7.1):

https://github.com/Albert-Gao/expo-router-dynamic-route

@Albert-Gao
Copy link
Author

Albert-Gao commented May 16, 2023

I kind of found the issue:

It seems the metro is not detecting any changes in the /app folder, no matter which project, I tried:

  • clear the watchman cache
  • pass -c to expo start
  • remove yarn.lock and reinstall,
    nothing works

metro doc says pass --reset-cache param when running, but this parameter has removed, tried updating my metro config to look like this, as the doc suggests, still not working...

module.exports = { ...getDefaultConfig(__dirname), resetCache: true };

In the $TMPDIR, I found a folder named metro-cache, removed it, now the files inside a sub-folder like /app/sub could be detected, but the files directly under the /app root can not...😂

I also removed the metro.config.js, in which it inherits the default config from expo/metro-config, expo-router/metro seems not there?

i do not know which one partially fixed it at this point 🤣

we need to have an easier way to completely nuke whatever metro has been cached...

-=======

tried again, although the file is being detected, but the changes to the file are not detected at all....

@smalik02
Copy link

Yeah - I cannot get it to work either. Have cleaned the project & rebuilt many times with no luck. Tested with adding dummy files in the root path under the app folder, but no routing luck. All giving the 404 error

@smalik02
Copy link

Nvm - this was due to not exporting function as default. Rough

@Albert-Gao
Copy link
Author

@smalik02 thanks, mate, that's a hard one😅

Must be an error when copying and pasting!

@Albert-Gao
Copy link
Author

Consider the human error is hard to eliminate but mitigate,
Can we have a better error message in this case, which we can read as:

file A in app folder has no default export, do you miss it?

Which would make it super easy to debug.

@EvanBacon @marklawlor

@Albert-Gao Albert-Gao reopened this May 29, 2023
@marklawlor marklawlor changed the title Unmatched route (Page not found) when doing from tab to another screen Feature Request: Unmatched route (Page not found) - warn when missing default export Jul 18, 2023
@sregg
Copy link

sregg commented Oct 15, 2023

I also lost about 1hr because of this.
It's very common to export React component using the named arrow function

export const Home = () => {...}

instead of

export default Home() {...}

I know it's written in the docs
image
but it would be great to either warn in the logs/app or allow for named exports.
Happy to help with a PR if needed.

@AndreiSager
Copy link

I also lost about 1hr because of this. It's very common to export React component using the named arrow function

export const Home = () => {...}

instead of

export default Home() {...}

I know it's written in the docs image but it would be great to either warn in the logs/app or allow for named exports. Happy to help with a PR if needed.

Thanks! This fixed my error. I forgot to write default for my home route.

@BalogunofAfrica
Copy link

Lost close to a day of debuging, a warning at least would help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants