본문 바로가기
React/React Basic

[React] 이모티콘 자료에서 뜻만 빼서 100자 까지만 보이기

by CodeMia 2022. 3. 15.

emojipedia.js 파일 내용 안에서 index.js로 meaning만 빼와보자. 

const emojipedia = [
{
id: 1,
emoji: "💪",
name: "Tense Biceps",
meaning:
"“You can do that!” or “I feel strong!” Arm with tense biceps. Also used in connection with doing sports, e.g. at the gym."
},
{
id: 2,
emoji: "🙏",
name: "Person With Folded Hands",
meaning:
"Two hands pressed together. Is currently very introverted, saying a prayer, or hoping for enlightenment. Is also used as a “high five” or to say thank you."
},
{
id: 3,
emoji: "🤣",
name: "Rolling On The Floor, Laughing",
meaning:
"This is funny! A smiley face, rolling on the floor, laughing. The face is laughing boundlessly. The emoji version of “rofl“. Stands for „rolling on the floor, laughing“."
}
];

export default emojipedia;


 

간단하게 map() 함수를 이용한다. 

 

 

emojipedia.map() 함수 안에 익명 함수를 넣는다. 

 

 

string을 100자까지 truncate 하기 

 

 

결과 담기 

 

결과 

index.js

 

 

 

 

댓글