Beginner question how to concatenate words


Topic: Beginner question how to concatenate words

Hans-Erik Hellberg asked 5 years ago

I´m new to this and testing the

MDBNotification

I have this code:

const ConnectedList = ({ badword }) => (
    <ul className="list-group list-group-flush">
        <MDBNotification
        show
        fade
        title="Bootstrap"
        message="Word is " + badword // Cannot add the badWord 
        text="11 mins ago"
        style={{
          position: "absolute",
          top: 0,
          right: 0
        }}
      />
    </ul>
);

I dont understand how to add badWord to the message?


Konrad Stępień staff answered 5 years ago

Hello @Hans-Erik Hellberg,

You need to use {} if you want to add js code to props.

We have two ways.

 message={"Word is " + badword}

or this

message={`Word is ${badword}`}

I prefer the second way.

Best regards, Konrad.


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.17.0
  • Device: win
  • Browser: chroom
  • OS: win
  • Provided sample code: No
  • Provided link: No