1

Actually i am getting values from props, I need to concat those values and put in JSX text element. But i am trying to appending it is not working. Is there any way to make this happen. I don't want to create any other variable to concat.

Code :

 <Text style={{marginTop = 15}}>{this.props.userinfo.token+this.props.userInfo.loggedin}</Text> 
1
  • Hi skyshine did you have any luck integrating a solution? Commented Jul 25, 2019 at 5:37

3 Answers 3

1

You can render them separately

 <Text style={{marginTop = 15}}>
   {this.props.userinfo.token}{this.props.userInfo.loggedin}
 </Text> 

OR

 <Text style={{marginTop = 15}}>
   {`${this.props.userinfo.token}${this.props.userInfo.loggedin}`}
 </Text> 
Sign up to request clarification or add additional context in comments.

Comments

0

userinfo !== userInfo

 <Text style={{marginTop: 15}}>
   {this.props.userInfo.token + this.props.userInfo.loggedin}
 </Text> 

You might also just have to verify that the props are active before trying to render them.

 <Text style={{marginTop: 15}}>
   { this.props.userInfo.token && this.props.userInfo.loggedIn ? (
      this.props.userInfo.token + this.props.userInfo.loggedin
    ) : (
      ""
   )}
 </Text> 

1 Comment

whatever code i have written that is working, i did one mistake, it should be like this <Text style={{marginTop : 15}}>
0

While the answers above are correct.

I just want to share that you can also do the following:

<Text style={{marginTop: 15}}>
  {this.props.userinfo.token.concat(this.props.userInfo.loggedin)}
</Text> 

Just make sure that this.props.userinfo isn't undefined nor null and has token and loggedin property.

And also this:

<Text style={{marginTop: 15}}>
  {`${this.props.userinfo.token}${this.props.userInfo.loggedin}`}
</Text> 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.