I am using localstorage to save user info after a successful login. Then I want to put a v-if condition to filter whether the user is logged in or not. But the problem is, the localStorage returning null while I am trying to parse it in components. I am sharing the codes from component here :

```
data() {
    return {
        currentUser : {}
    }
},

mounted() {
    this.currentUser = localStorage.getItem('userInfo')
}

```

From the Template :

```
<span v-if="currentUser" class="dropdown-item dropdown-header text-right">{{ currentUser.name 
}}</span>

```

From console :

[![enter image description here](https://i.stack.imgur.com/NPdSt.png)](https://i.stack.imgur.com/NPdSt.png)