1
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.

reactのコンポーネントの書き方メモ

Posted at

reactのコンポーネントの書き方

app.js

import React from 'react';
import logo from './logo.svg';
import './App.css';

import TestComponent from './components/TestComponent.js';
import ButtonComponent from './components/ButtonComponent.js';

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload!!!!!.
        </p>
        <TestComponent text="うふふふ" />
        <TestComponent text="あははは" />
        <ButtonComponent text="あははは" bgColor="red" />
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}

export default App;

TestComponent.js


import React from "react";
import styled from "styled-components";


const TestComponent = props => {
  return (
    <Test>
      {props.text}
    </Test>
  );
};

const Test = styled.p`
  padding: 0 40px 40px 40px;
  font-size: 1.4rem;
`;

export default TestComponent;


1
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
1
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?