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

<Routes> received an unexpected slot "default". #981

Closed
vfilatov opened this issue Apr 12, 2021 · 29 comments
Closed

<Routes> received an unexpected slot "default". #981

vfilatov opened this issue Apr 12, 2021 · 29 comments

Comments

@vfilatov
Copy link

vfilatov commented Apr 12, 2021

Describe the bug
Recently appeared in a dev tool three warnings.

Logs
received an unexpected slot "default". index.mjs?v=76284753:1656
was created with unknown prop 'status' index.svelte:2
was created with unknown prop 'error' index.svelte:2

To Reproduce
npm init svelte@next
npm install
npm run dev
in browser, open dev tool and navigate to http://localhost:3000

@frederikhors

This comment has been minimized.

@vfilatov
Copy link
Author

looks fixed in "SvelteKit v1.0.0-next.74"

@vfilatov
Copy link
Author

I was wrong, it still throws a warning.
<Routes> received an unexpected slot "default".

@vfilatov vfilatov reopened this Apr 13, 2021
@mcdba

This comment has been minimized.

@higoka

This comment has been minimized.

@rchrdnsh

This comment has been minimized.

@asv7c2

This comment has been minimized.

@Rich-Harris
Copy link
Member

People, you don't need to comment saying that the warning is still there. As long as the issue remains open you can assume it's still there — that's how issues work :)

@rchrdnsh

This comment has been minimized.

@pngwn
Copy link
Member

pngwn commented Apr 18, 2021

It is just a dev-time warning, none of these show up in the production build.

@jakobrosenberg
Copy link

Could this issue be addressed at Svelte level? For package creators it would be nice to be to able to tell Svelte to filter harmless warnings produced by the package.

Something like

window.__svelteMsgFilter = msg => msg !== 'ignore me'

@Rich-Harris
Copy link
Member

I think it'll have to be addressed at a Svelte level somehow, yeah

@PuruVJ
Copy link
Contributor

PuruVJ commented May 6, 2021

I'm having this warning when routing to other pages, just like your case. However, If I navigate to a page whose path isn't / (/blog or /works), it shows the $error page instead.

Something might have gone wrong moving from Sapper to Sveltekit 😔 https://github.com/puruvj/puruvjdev3-svelte

Anyone else facing the same issue?

@ebeloded
Copy link

Is this issue being tracked in Svelte repository? I am finding PRs addressing similarly sounding issues being merged and issues closed.

@bluebrown
Copy link

so, not a big deal, of course, as nothing breaks in development and they don't show up in production...just...you know...the warnings do add up and pollute the console quite a bit :-)

It is refreshing the browser page, not just polluting the logs. It makes literally a new network request to get resources each time it throws that warning.

@LLIETAER
Copy link

LLIETAER commented Jun 27, 2021

I notice is you add the "slot" tags in your pages it suppress the log. I seems logical as somehow a default slot content is provided to pages.

@M1sf3t
Copy link

M1sf3t commented Jul 7, 2021

That warning has been showing up since I first started using sapper two years ago, no idea what causes it but it's yet to cause an actual issue

@AshishKapoor
Copy link

AshishKapoor commented Jul 15, 2021

So the default slot inside __layout needs to be named? The warning isn't showing up in production build though.

@rchrdnsh
Copy link

I think it's much more involved than that, as I get a warning for every exported prop on every page all the time always. I will have hundreds upon hundreds of these warnings when in development...it's no fun, to be sure, but as you say, they do not show up in production...dunno at this point if this is a bug or a feature...maybe a little Stockholm Syndrome? 🤪

@basaran
Copy link
Contributor

basaran commented Jul 24, 2021

Has anyone found a solution to this issue? I tried naming the slot in __layout file, but I'm not sure how to use it in the page.

<div slot="pika">
    <h3>Welcome to Carbon</h3>
    <p>
        Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a>
        to read the documentation.
    </p>
</div>

is coming back with a nicely formatted:

Element with a slot='...' attribute must be a child of a component or a descendant of a custom element

@fourglobe302500
Copy link

This issue is happening to me in another way. I just created a new project via npm init svelte@next <app-name> and created a __layout.svelt file. But the layout does not render and the only thing that shows any sign of error is this <Routes> received an unexpected slot "default".

@ibilux
Copy link

ibilux commented Aug 7, 2021

This seem to do the trick for now!
{#if false}<slot/>{/if}

For some unknown reason the components are receiving an unexpected slot "default" (unnamed slot), while the component don't have a default slot <slot/>.

@benmccann
Copy link
Member

Closing this in favor of the issue in the Svelte repo since that's where this would need to be solved sveltejs/svelte#6325

@CJ13th
Copy link

CJ13th commented Dec 22, 2021

This issue is happening to me in another way. I just created a new project via npm init svelte@next <app-name> and created a __layout.svelt file. But the layout does not render and the only thing that shows any sign of error is this <Routes> received an unexpected slot "default".

Check which version of Svelte you are running, I was running 3.44.0 but after I updated to 3.44.3 the issued resolved itself.

moritzlaube added a commit to moritzlaube/astro that referenced this issue Jan 3, 2022
I am having funny console logs saying that my svelte component `received an unexpected slot "default".`. This issue is described here: sveltejs/kit#981

Supposedly, updating svelte to version 3.44.3 solves this issue. I couldn't test it, though.
matthewp pushed a commit to withastro/astro that referenced this issue Jan 4, 2022
* Update svelte version in renderer-svelte

I am having funny console logs saying that my svelte component `received an unexpected slot "default".`. This issue is described here: sveltejs/kit#981

Supposedly, updating svelte to version 3.44.3 solves this issue. I couldn't test it, though.

* Update Svelte to 3.44.3 to get rid of console warning that component receives an unexpected slot "default".
@moritzlaube
Copy link

Does anyone know the reason why this is happening? I issued a pull request for astros svelte renderer to update to the latest svelte version 3.44.3 but the issue persists. It's not a deal breaker. It's only annoying when you get the same warning for every svelte-component you use. Cheers!

@kylesloper
Copy link

Does anyone know the reason why this is happening? I issued a pull request for astros svelte renderer to update to the latest svelte version 3.44.3 but the issue persists. It's not a deal breaker. It's only annoying when you get the same warning for every svelte-component you use. Cheers!

Glad it's not just me seeing this in Astro then. Have you found a way to deal with it?

@moritzlaube
Copy link

Unfortunately, I haven't …

@divStar
Copy link

divStar commented Sep 17, 2022

Weird.. using Svelte (not SvelteKit) and Routify (V3), I also get these warnings and their variations at _module.svelte-level.

<Module> was created with unknown prop 'context' [_module.svelte:163:92](http://localhost:5173/src/routes/_module.svelte?t=1663453395158)
<Noop> was created with unknown prop 'date' [Noop.svelte:86:92](http://localhost:5173/node_modules/@roxi/routify/lib/runtime/decorators/Noop.svelte?v=d4cd57d8)
<U5Bdateu5D> received an unexpected slot "default". [index.mjs:2084:20](http://localhost:5173/node_modules/svelte/internal/index.mjs)
<U5Bdateu5D> was created with unknown prop 'context' [index.svelte:465:92](http://localhost:5173/src/routes/calendar/[date]/index.svelte?t=1663453239282)

No clue what's causing them...

@jakobrosenberg
Copy link

@divStar it's Svelte that generates these, not Kit. They occur when you pass a prop to a component, but the component doesn't have a corresponding export let <prop>. In your case R3 passes a context prop to the component.

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