2

How do render string along with html tag in react. I just want to add redirecting in 10 seconds to next line but I'm getting [object object] instead.

tip={"Please wait!" +<br/ >+"Redirecing in 10 seconds..."}

enter image description here DEMO: CodeSandbox Link

6 Answers 6

2

According to the Doc :

Tip should be a string , use \n for line breaks and add whiteSpace: "break-spaces to the style of the Spin:

<Spin tip={"Please wait! \n Redirecing in 10 seconds..."} style={{ whiteSpace: "break-spaces"}}>

ReactDOM.render(
  <antd.Spin tip={"Please wait! \n Redirecing in 10 seconds..."} style={{ whiteSpace: "break-spaces"}}>
    <antd.Alert
      message="Alert message title"
      description="Further details about the context of this alert."
      type="info"
    />
  </antd.Spin>,
  document.getElementById("container")
);
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/antd/4.0.2/antd.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/antd/4.0.2/antd.min.js"></script>
<div id="container"></div>

Sign up to request clarification or add additional context in comments.

Comments

0

you can try like this:

<Spin tip={<span><br />"Loading..."</span>}>

Comments

0

You can try add "\n" into the string

Comments

0

You should put everything inside a jsx tag without quotes and concatenation, like this:

tip={<span>Please wait!<br/ >Redirecing in 10 seconds...</span>}

Comments

0

It might be something like <Spin tip={[<br />, "Loading..."]}>.

Comments

0

You can not send HTML tags inside Spin component of ant design spin prop.

It will always consider it a string and will not render the HTML.

I think this helps to prevent unnecessary code into our app.

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.