Skip to content
This repository has been archived by the owner on Apr 12, 2020. It is now read-only.

store.subscribe is not a function #58

Closed
JefferyHus opened this issue Nov 2, 2019 · 9 comments
Closed

store.subscribe is not a function #58

JefferyHus opened this issue Nov 2, 2019 · 9 comments

Comments

@JefferyHus
Copy link

The moment I add this to my App.svelte:

  <Router>
    <Route exact path="/" component={Products} />
  </Router>

This error is being thrown: store.subscribe is not a function. I have not digg deep to check the source of the problem and tend to ask first if anyone had this before. Otherwise I must be skeptical about the source code of svero.

@kazzkiq
Copy link
Owner

kazzkiq commented Nov 2, 2019

I just cloned sveltejs/template, ran npm i svero, replicated your <Route> and everything worked normally. No problems whatsoever.

Can you please provide more info on your project stack?

@JefferyHus
Copy link
Author

I have svelte 3.12.1

@pateketrueke
Copy link
Contributor

Top-level usage seems to be OK but hidden complexity could be within Products, can you please share that too?

@JefferyHus
Copy link
Author

JefferyHus commented Nov 4, 2019

I have moved to SSR as I was in a hurry but so far this is what I had:

App.svelte

<script>
    import { Router, Route } from 'svero';
    import Products from './components/Products.svelte'; 
</script>

<Router>
    <Route exact path="/" component={Products} />
</Router>

Products.svelte

<script>
    import { onMount } from 'svelte';
    import { items } from './stores';

    let products;
  
    items.subscribe(value => {
      products = value;
    });
    // Fetch products
    ....
</script>


<div>
{#each products as item}
...
{/each}

Nothing complicated here, then while debugging I found that by removing the Router component part, the error disappears. So I suspect something is not compatible with the latest version.

@pateketrueke
Copy link
Contributor

I managed to run your example locally, without issues, also using svelte@3.12.1.

How you're integrating your code with svelte-tooling? Probably there's a problem we can't see. 🤔

@JefferyHus
Copy link
Author

That's weird, I will have to try it our again and digg deep to find the issue. If you guys are having no problem so I may suspect webpack configuration (even tho it doesn't relate that much). What happens exactly is that the store object is overwritten in the runtime, this must be related to svelte itself and how it is parsing child components.

@pateketrueke
Copy link
Contributor

Hi, @JefferyHus if you want you can try yrv as a drop-in replacement to svero, thank you!

@jhechtf
Copy link

jhechtf commented Feb 2, 2020

I'm also having the same issue with even a basic usage with svelte 3.17.1 and Svero 1.0.0

<!-- App.svelte -->
<script>
import {Router, Route} from 'svelte';
</script>
<Router>
  <Route path="*">Testing</Route>
</Router>

I'm using webpack, could that be causing the issue?

@kazzkiq
Copy link
Owner

kazzkiq commented Apr 12, 2020

Svero is now deprecated. Check #68 for alternatives.

@kazzkiq kazzkiq closed this as completed Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants