Error 'Function called outside component initialization' when calling route.meta()
See original GitHub issueFirst of all, congrats for this amazing component.
I’m trying to get route information through route.meta()
function inside an Svelte’s onMount()
, but I’m getting the follow error message: Function called outside component initialization
I just tried to use example at https://github.com/AlexxNB/tinro/#route-meta in a fresh app, but without success.
I’ve added an example in REPL to show the problem (it’s the first page of Svelte quickstart template): https://svelte.dev/repl/9f8ca34b8aef4b6e88f1eb64c1eff27f?version=3.32.1
PS.: If I call route.meta()
as is in the example, the message changes to Cannot read property 'meta' of undefined
.
Anything I’m doing wrong? Or is it a bug?
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
I get "Function called outside component initialization" when ...
After some debugging I found that error: Function called outside component initialization only happens on the dev server, on the client and ...
Read more >Function called outside component initialization #592 - GitHub
This component is calling onMount, beforeUpdate, afterUpdate, or onDestroy. I tried moving onMount into a setTimeout & the same issue occurs.
Read more >Router tutorial: tour of heroes - Angular
Define an array of routes, appRoutes , and pass them to the RouterModule.forRoot() method. The RouterModule.forRoot() method returns a module that contains ...
Read more >Using a store outside of a component - Pinia
The easiest way to ensure this is always applied is to defer calls of useStore() by placing them inside functions that will always...
Read more >Backbone.js
Note that calling model.off(), for example, will indeed remove all events on ... If you define an initialize function, it will be invoked...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@OysterD3
The solution mentioned here seemed to get
router.goto
working for me. Example vite.config.js:That’s it. I was using a component outside an outer
Route
.Thanks, @AlexxNB.