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

Further instructions on how to use 'meta' needed #58

Closed
kane81 opened this issue Mar 17, 2021 · 3 comments
Closed

Further instructions on how to use 'meta' needed #58

kane81 opened this issue Mar 17, 2021 · 3 comments

Comments

@kane81
Copy link

kane81 commented Mar 17, 2021

Hi

according to the readme you can access meta data using the following code

<script>
    import {meta} from 'tinro';
    const route = meta();  
</script>

I however cannot seem to get this code to work... I have added it to my App.svelte and I get an error

Uncaught TypeError: Cannot read property 'meta' of undefined
    at g (tinro_lib.js:1)
    at instance (App.svelte:12)
    at init (index.mjs:1474)
    at new App (App.svelte:48)
    at main.js:3
    at main.js:8

I have added the code into the repl example and get Cannot read property 'meta' of undefined

can you please add more guidance on how to init this property so we do not get this error. I have tried putting it in onMount() of App.svelte too and get the same error.

Thank you

@kane81 kane81 changed the title How to use meta Further instructions on how to use 'meta' needed Mar 17, 2021
@OysterD3
Copy link

You need to use it in the component that wrap with <Route></Route>

@AlexxNB
Copy link
Owner

AlexxNB commented Mar 18, 2021

Yes, @OysterD3 is right. Most meta info is route specific, that is why it should be involved only from a child component of any <Route>.
But, I think more explicit error message should helps to use meta in the right way. I'll add it.

@AlexxNB
Copy link
Owner

AlexxNB commented Mar 18, 2021

If you need none-route specific data like path, hash or query use router subscription or route.location methods.

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

3 participants