4
return(
  <div>
    <Loading loadingMessage="Running "{this.state.programName}" program"/>
  </div>
);

I know that above attribute loadingMessage value is syntactically wrong. But my need is, I need to get that programName from state and append to loadingMessage attribute value. How can I do this? Any help will be appreciated.

1 Answer 1

5

You can write javascript inside the curly brackets, just concatenate the string in there.

return (
    <div>
        <Loading
            loadingMessage={"Running " + this.state.programName + " program"}
        />
    </div>
);

or use a template literal:

<Loading loadingMessage={`Running ${this.state.programName} program`}/>
Sign up to request clarification or add additional context in comments.

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.