초보자를 위한 매핑 개념
import { Card, datas } from "../src/components/Card";
import "../src/components/Card.css";
import "./App.css";
// import { stringify } from "querystring";
const App = () => {
/
return (
<div className="main">
{
datas.slice(0,3).map((val: { title: string; desc: string; id: number; createdDate: string; }) => {
return (
<Card
title={val.title}
desc={val.desc}
id={val.id}
createdDate={val.createdDate}
/>
);
})}
</div>
);
};
export default App;
구성 요소/card.tsx
export interface ICard {
title: string;
desc: string;
id: number;
createdDate: string;
}
export const datas : ICard[] = [
{
title: "ABC",
id: 1,
desc: "this is desc1",
createdDate: "12/03/2020"
},
{
title: "DEX",
id: 2,
desc: "this is desc1",
createdDate: "17/03/2020"
},
{
title: "IJK",
id: 3,
desc: "this is desc1",
createdDate: "2/03/2020"
},
{
title: "LMN",
id: 4,
desc: "this is desc1",
createdDate: "12/04/2020"
},
];
export const Card: React.FC<ICard> = ({ title, desc, id, createdDate }) => {
return (
<>
<div className="all">
<h3>{id}</h3>
<h1>{title}</h1>
<p className="desc">{desc}</p>
<div>{createdDate}</div>
</div>
</>
);
};
Flagicon.tsx
import React from "react";
import ReactDOM from "react-dom";
interface IOption {
label: string;
value: string;
flagImg: string;
type?: any;
}
const isOption: IOption[] = [
{ label: "Nepal", value: "nepal", flagImg: "nepal" },
{ label: "Canada", value: "canada", flagImg: "canada" },
{ label: "South Korea", value: "south-korea", flagImg: "sk" },
{ label: "USA", value: "USA", flagImg: "usa" },
];
export const SelectOption = () => {
return (
<div className="select-option">
<Select
// isFormatOptionLabel={isFormatOptionLabel}
options={isOption}
/>
</div>
);
};
textbox.tsx
interface IconProps {
src: string;
alt: string;
style?: object;
className?: string;
}
interface TextProps {
type: string;
placeholder?: string;
value?: string;
onChange?: () => {};
style?: object;
className?: string;
}
interface TextInputProps {
iconProps: IconProps;
textProps: TextProps;
selectProps: SelectProps;
optionProps: OptionProps[];
// iconcountryProps: IconcountryProps;
}
interface SelectProps {
id: string;
className: string;
}
interface OptionProps {
value: string;
label?: string;
className?: string;
}
export const Textbox: React.FC<TextInputProps> = ({
iconProps,
selectProps,
optionProps,
textProps,
// iconcountryProps,
}) => {
return (
<div className="inputbox">
<img {...iconProps} />
<input {...textProps} />
<select {...selectProps}>
{optionProps.map((val) => {
return (
<option {...val.value} {...val.className}>
{val.label}
</option>
);
})}
</select>
</div>
);
};
카드.css
.desc {
padding: 4rem;
font-size: 24px;
}
.image {
height: auto;
width: auto;
}
.all {
margin: 30px;
border: 1px solid black;
box-shadow: 3px 3px 5px 6px #ccc;
padding: 30px;
height: 400px;
width: 400px;
}
Reference
이 문제에 관하여(초보자를 위한 매핑 개념), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/entrepreneur123/mapping-concept-for-beginner-188o텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)