vendredi 23 novembre 2018

Use React's Link to and if statement

so I want to link to different pages of my site when a specific string is active (in this case when the string is 'got' from local storage). See below please:

displayCharacterProfile() { let getCharacterName = localStorage.getItem("characterName");

    if(getCharacterName == "littlefinger") {
        <Link to="/littlefinger"></Link>
    }
    if(getCharacterName == "tywin") {
        <Link to="/tywin"></Link>
    }

}

render() { return ( Enter

Aucun commentaire:

Enregistrer un commentaire