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

Provide a way for layouts to determine if current page is an error page #598

Closed
benmccann opened this issue Mar 23, 2021 · 5 comments
Closed
Labels
feature request New feature or request help wanted PRs welcomed. The implementation details are unlikely to cause debate
Milestone

Comments

@benmccann
Copy link
Member

In Sapper we did sveltejs/sapper#1498

Suggestion from Rich for SvelteKit:

Given that it only applies to the root layout I think I'd prefer that we pass the error (and possibly status) as a prop. It doesn't belong on the page store

@benmccann benmccann added feature request New feature or request pkg:kit labels Mar 23, 2021
@Rich-Harris Rich-Harris added the help wanted PRs welcomed. The implementation details are unlikely to cause debate label Mar 24, 2021
@Rich-Harris
Copy link
Member

Created a new straightforward label for issues like this that should be pretty easy to implement since they don't touch a bunch of different places. In this case I think we just need to add a prop here...

<Layout {...(props_0 || {})}>
...and add a test.

The one downside of this approach is that we'll get created with unknown prop warnings in dev if the root layout doesn't expose an error prop, but that's not the worst thing in the world

@Conduitry
Copy link
Member

Could we partially relieve that by having the starter template define the prop in the root layout, even if it doesn't use it? That might not be worth it though, and would add bytes to the prod version just to avoid a dev time warning. I'm torn.

@Rich-Harris
Copy link
Member

I think Svelte should probably skip the warning in cases where the prop is undefined anyway.

Relatedly, we have a similar problem with it often warning that a default slot was provided to a leaf component

@Rich-Harris Rich-Harris added this to the 1.0 milestone Mar 24, 2021
@benmccann benmccann removed the pkg:kit label Mar 24, 2021
@Conduitry Conduitry mentioned this issue Apr 4, 2021
@Rich-Harris Rich-Harris mentioned this issue Apr 6, 2021
5 tasks
@Rich-Harris
Copy link
Member

We decided that the best way to do this would be

import { status, error } from '$app/stores';

@Rich-Harris
Copy link
Member

closed via #3096

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request help wanted PRs welcomed. The implementation details are unlikely to cause debate
Projects
None yet
Development

No branches or pull requests

3 participants