lundi 23 août 2021

Reactjs IF statement

I have a component I call that is a passed a recordID and returns the text associated to the Id. 33 should = Tower

will render "Tower" on the screen. All good, but...

When I try to use the component in the following IF statement it does not work.

...

if (<GetAssetTypeNameComponent datafromparent = {assettype_assettypeId}/> === "Tower")
{ 
    this.props.history.push(`/add-assetstower/${assetsid}/${this.props.match.params.sitemasterid}`);
}

Using the passed parameter does work if I change the code to:

...

if (assettype_assettypeId === "33")
        { 
            this.props.history.push(`/add-assetstower/${assetsid}/${this.props.match.params.sitemasterid}`);
        }

...

What am I doing wrong?

Rob

Aucun commentaire:

Enregistrer un commentaire