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;