question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

spa_router.js:106 Uncaught TypeError: Cannot read property 'isActive' of undefined

See original GitHub issue

active class not working

<header>
  <a href="/" class="logo"><img src="/logo.svg" alt="META_TITLE" border="0" /></a>
  <section>
    <p>META_DESCRIPTION</p>
    <nav>
        <a href="/news" class:active={routeIsActive('news')}>News</a>
        <a href="/social" class:active={routeIsActive('social')}>Social</a>
        <a href="/videos" class:active={routeIsActive('videos')}>Videos</a>
        <a href="/blogs" class:active={routeIsActive('blogs')}>Blogs</a>
        <a href="/podcasts" class:active={routeIsActive('podcasts')}>Podcasts</a>
        <a href="/supplies" class:active={routeIsActive('supplies')}>Supplies</a>
        <a href="/links" class:active={routeIsActive('links')}>Links</a>
      
    </nav>
  </section>
</header>
<script>
  import { routeIsActive } from 'svelte-router-spa'
  export let currentRoute = {};

    // import { link, push } from 'svelte-spa-router'
    // import active from 'svelte-spa-router/active'
</script>

<style>
header {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    background-color: #fff;
    box-shadow: 0px 3px 40px rgba(0, 0, 0, 0.12);
    z-index: 2;
    padding: 0;
}

header section {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
}

header .logo {
  padding: 0;
  margin-right: 3rem;
}

header p {
  margin: 1rem;
}

header img {
  height: 8rem;
}

nav {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    flex-direction: column;
    flex-wrap: nowrap;
    list-style-type: none;
    width: 100vw;
    overflow-y: auto;
    max-height: 13rem;
}

nav a {
    display: block;
    padding: 1rem;
    border: 1px solid transparent;
    color: #212121;
    font-weight: 400;
    text-decoration: none;
}

:global(nav a.active) {
    color: var(--link-color) !important;
    font-weight: 700 !important;
}

@media all and (orientation: landscape) {
    header {
        height: auto;
        flex-direction: row;
        padding: 0 11rem;
        align-items: flex-start;
    }

    nav {
        flex-direction: row;
        justify-content: flex-start;
    }

    :global(nav a.active) {
            border-bottom: 2px solid var(--active-color) !important;
    }
}
</style>
<script>
  import { Router } from 'svelte-router-spa'
  import routes from './routes';
  import Topnav from './components/Topnav.svelte';
  import Footer from './components/Footer.svelte';

  export let currentRoute = {};

</script>

<main>
	<Topnav {currentRoute} />
    <div id="body">
        <Router {routes} options={ {gaPageviews: true} } />
    </div>
    <Footer />
</main>

<style>

main {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex-direction: column;
}

#body {
	padding: 31rem 1rem 1rem;
  max-width: 100vw;
  margin: 0 auto;
  overflow-y: auto;
}

@media all and (orientation: landscape) {
    #body {
      padding: 1rem;
      margin-top: 11rem;
      max-width: none;
    }
}
</style>

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
JCHHeilmanncommented, Jun 20, 2020

I’m having the same issue.

2reactions
drannex42commented, Apr 14, 2020

Any update or method of fixing this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read properties of undefined ...
I am creating an ecommerce with react. I'm trying to create a function who shows the product details. But I do not know...
Read more >
Cannot read property 'get' of undefined
Hello everyone! I created a purchases controller to take data from user input, but I have an error; routes/purchases.js: import Route from ...
Read more >
svelte-router
Then I tried converting this example project from svelte-spa-router to ... spa_router.js:106 Uncaught TypeError: Cannot read property 'isActive' of ...
Read more >
Error: Cannot read property '_display' of undefined
Hi, I am getting the below error "Uncaught TypeError: Cannot read property '_display' of undefined" when I try to executes the SAPUI5 ...
Read more >
Cannot read properties of undefined' - JavaScript Debugging
How To Fix ' Uncaught TypeError : Cannot read properties of undefined ' - JavaScript Debugging. Watch later. Share. Copy link.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found