https://www.youtube.com/watch?v=j-JxASock0Q
npm install styled-components@5
src-App.js--------------------
import React, { Children } from 'react';
import styled from 'styled-components';
const SimpleButton = styled.button`
color: white;
background-color: green;
`;
const LargeButton = styled(SimpleButton)`
font-size: 50px;
`;
const ReactButton = props => {
console.log('props: ',props);
return <button className={props.className}>{props.children}</button>
}
const ReactLargeButton = styled(ReactButton)`
font-size: 50px;
`;
// const PrimaryButton = styled.button`
// color: ${function(props) {
// console.log('props=============== ', props);
// if(props.primary){
// return 'white';
// } else {
// return 'black';
// }
// return 'blue';
// }};
// `;
const PrimaryButton = styled.button`
color: ${props => props.primary ? 'white' : 'black'};
background-color: ${props => props.primary ? 'blue' : 'gray'};
`;
const App = () => {
return (
<div>
<SimpleButton>Simple</SimpleButton>
<LargeButton>Large</LargeButton>
<ReactButton>React</ReactButton>
<ReactLargeButton>React Large</ReactLargeButton>
<PrimaryButton>Normal</PrimaryButton>
<PrimaryButton primary>Primary</PrimaryButton>
</div>
);
};
export default App;
'컴퓨터 > react' 카테고리의 다른 글
React Hooks에 취한다 - 리액트 훅스 쉽게 마스터하기 (0) | 2023.05.18 |
---|---|
react mysql (0) | 2023.04.28 |
React egoing (0) | 2023.04.20 |
React JS 이론부터 실전까지 - 동빈나 (0) | 2023.04.07 |
react Module not found: Error: Can't resolve './serviceWorker' in (0) | 2022.07.04 |