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 3 years have passed since last update.

ファイルにコンポーネントが散らばった

Posted at

覚書です。

ディレクトリで整理するほどでもないけど、細かく仕分けたら一つのファイルに大量のコンポーネントが散乱してしまったときの対処法です。画面に表示されるコードが少なくなります。
IDEやテキストエディタなどに付属しているコード領域の展開/折り畳みの機能がないとあまり効果を発揮できません。

import React from 'react'
import styled from '@emotion/styled'

const Hoge = {
  Wrapper: <div>...</div>,
  P: styled.p`
    ...;
  `,
}

const HogePage: React.VFC = () => (
  <Hoge.Wrapper>
    <Hoge.P>hoge</Hoge.P>\
  </Hoge.Wrapper>
)

これでHogeオブジェクトでコードの折り畳み機能を使うと一行にまとまってくれるので画面がスッキリします。
ランディングページ等で活躍します。

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?