Back to list
jakewaldrip

react-component-writing

by jakewaldrip

Dotfile configuration for my environment

3🍴 0📅 Jan 7, 2026

SKILL.md


name: react-component-writing description: React component style guide

React components

Guidelines

  • Export a named variable export const ExampleComponent. Avoid default exports.
  • Avoid spread props {...props} in GraphQL wrapper components. List all the props individually to improve type safety and linting.
  • Format the component function as a plain arrow function. Do not type with React.FC.

UI components

For components that do not use GraphQL queries, writing UI components is straightforward. See example example-ui-component.tsx.

GraphQL components

For components that use GraphQL queries, component structure is separated into two components: the UI sub-component ExampleComponentUI and the GraphQL wrapper component, ExampleComponent. See example example-graphql-component.tsx.

Jest tests with GraphQL components

Jest tests for GraphQL components can be written in two ways:

  1. Test the UI sub-component, set props directly. See example-graphql-component-ui.spec.tsx
  2. Add GraphQL mocks. See example-graphql-component-mocks.spec.tsx

Internationalization

Most components use MessageFormat type to render internationalization text.

To render MessageFormat to a string, use useFormatMessage from Commonplace, as it is properly typed for MessageFormat. Do not use useIntl from react-intl.

import { Text, useFormatMessage } from '$commons/app/shared/commonplace';

const Component = ({ pageNumber }: { pageNumber: number }) => {
  const formatMessage = useFormatMessage();
  const nextText = formatMessage({ id: 'shared.next' });
  return <Text text={`${nextText}: ${pageNumber}`} />;
};

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon