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.

`Cannot read property '_t' of null` when switching layouts

See original GitHub issue

Version

v6.6.0

Reproduction link

https://gitlab.com/musiciansbass/musiciansbass-app

Steps to reproduce

I am using a modal plugin called Sweetalert2. This is the method I use to instantiate the popup:

    showLogin(bus) {
      if (process.client) {
        // popup =
        this.$swal({
          ...this.popupOpts,
          title: this.$t('login.cta.login'),
          html: '<div id="alert-content"></div>',
          onOpen() {
            bus.emit('loadLoginForm')
          },
          onClose() {
            bus.emit('closePwForm')
          }
        })
      }
    },

This works just fine if I load my homepage (which uses one layout) or I enter from a different URL (a page using a different layout) and click the login button. If I click between internal pages which use the same layout and click login, everything works as expected.

If, however, I am on an internal page and click to return to the homepage (which switches layouts), or if I am on the homepage and click to an internal page (again, switching layouts) and I click the login button, I get the following error:

TypeError: Cannot read property '_t' of null
    at VueComponent.Vue.$t (vue-i18n.esm.js?a925:178)
    at VueComponent.showLogin (Login.vue?7463:65)
    at eval (Login.vue?7463:47)
    at eval (mitt.es.js?14b7:57)
    at Array.map (<anonymous>)
    at Object.emit (mitt.es.js?14b7:57)
    at click (Buttons.global.vue?e4ea:27)
    at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
    at HTMLButtonElement.invoker (vue.runtime.esm.js?2b0e:2179)
    at HTMLButtonElement.original._wrapper (vue.runtime.esm.js?2b0e:6917)
    at HTMLButtonElement.sentryWrapped (helpers.js?bf37:71)

And indeed, if I console.log the component, _i18n and $i18n are null:

VueComponent {_uid: 22, _isVue: true, $options: {…}, _renderProxy: Proxy, _self: VueComponent, …}
[...]
_i18n: null
[...]
$i18n: null
[...]
__proto__: Vue

My navigation URLs are all variations of:

<nuxt-link class="hoverline" :to="localePath(item.slug)">{{ item.title }}</nuxt-link>

Oddly, none of the components outside of the modal are having any trouble using the $t method. Only the modal has the problem. And I’m not doing anything asynchronously in terms of loading the modal itself, which I saw in a related issue as one proposed pain point.

Any help would be greatly appreciated.

Thanks

What is expected ?

For the i18n object to not vanish from my Vue component when invoked in a modal window after changing layout contexts.

What is actually happening?

The i18n object is vanishing from my Vue component when invoked in a modal window after changing layout contexts.

<div align="right">This bug report is available on Nuxt community (#c406)</div>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
selfagencycommented, Mar 3, 2020

Ok, if I take the $t’s out of my component methods and put them in as data, I can access them through this. Better than nothing!

0reactions
selfagencycommented, Mar 3, 2020

Wait, no it didn’t. FFFFFFUUUUUUUU.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property '_t' of null when switching layouts #621
I am using a modal plugin called Sweetalert2. This is the method I use to instantiate the popup: showLogin(bus) { if (process.client) {...
Read more >
React: TypeError: Cannot read properties of null ...
One possible reason of such error is to have multiple versions of react . This can be checked by a shell command like...
Read more >
Cannot read properties of null (reading '_gsap') - GSAP
Hi, i am having an issue on using the Flip plugin in React Js. I have a flip animation occuring in a page....
Read more >
cannot read properties of null (reading 'usecontext') jest - ...
As the title says, I'm using React. I'm using Axios to connect the frontend to the backend. I'm using Jest to test it....
Read more >
Error : Can't read property 'GetCollisionEngine' of null
Hi. I have an error when I change the layout in my game. When I start my game with the first layout, all...
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