Skip to content

How to use localStorage in componentWillMountΒ #9647

@BhumiSukhadiya

Description

@BhumiSukhadiya

I am learning react js and i want to check if authentication token is set or not in localStorage before the component renders.
Currently i am trying to do it inside componentWillMount method, but it gives me warning that localStorage is not defined.
So how can i access localStorage?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions