0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Reactで<br/>を使用せずに改行する

Posted at

#背景

Reactのアプリケーションで、バックエンドから改行を含む文字列を変数で受け取って、フロントエンドで改行させる方法を調べていたら様々な方法があったので個人的にお気に入りな方法をまとめておく。

#実装方法

sample.tsx
import "./styles.css";

export default function App() {
  const val: string = {バックエンドから取得する処理};
  return (
    <div className="App">
      <h1 className="text">{val}</h1>
    </div>
  );
}
styles.css
.text {
  white-space: pre-wrap;
}

#参考記事
https://zenn.dev/kanasugi/articles/b0547f5ae1f522

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?