Home > other >  Create new line with react tsx not working
Create new line with react tsx not working

Time:10-15

I want to set the username on a new line in my React tsx (TypeScript) web application.

Please upvote this question bec. it isn't too easy to find the solution in the internet so others also see the solution here :)

entry.comment contains the following string: jsdkjfdjsfds
entry.username contains the following string: Noah

My code looks like this, I tried with \n but this isn't working:

<div className={classes.entryContent}>
  <Typography className={classes.entryContentParagraph} variant="body2" paragraph={true}>
    <ReactMarkdown>
      {entry.comment   "\n"   entry.username}
    </ReactMarkdown>
  </Typography>
</div>

Picture with the not working line break

Do you have an advice? Stay fresh!

CodePudding user response:

According to this issue and to markdown conversions

enter image description here

will give you

enter image description here

but this

enter image description here

will give you

enter image description here

CodePudding user response:

Since I don't have enough reputation I have to add it in an answer.

I haven't worked with this library before but can you try adding the break-line tag, like <br />.

CodePudding user response:

<div className={classes.entryContent}>
  <Typography className={classes.entryContentParagraph} variant="body2" paragraph={true}>
    <ReactMarkdown>
      <p>{entry.comment}</p>
      <p>{entry.username}</p>
    </ReactMarkdown>
  </Typography>
</div>
  • Related