0
반응이 배우고 있으며 JS에 익숙하지 않은 사람도 있습니다. 한 구성 요소에서 .map 기능이 작동하지만 다른 구성 요소에서 작동하지 않는 이유를 말해 줄 수 있습니까? ?props.data.map이 내 구성 요소에서 작동하지 않습니다.
지도
import React from 'react';
import Card from './card';
import '../memoryGameStyle/cardList.css';
const CardList =(props)=>{
const card=props.cards.map((c,i)=>(
<Card
key={i}
card={c}
cards={props}
/>
))
return(
<div className='card-list'>
{card}
</div>
)
}
export default CardList;
하지만이 구성 요소에서 작동하지 않습니다이 구성 요소에서 잘 작동
import React from 'react';
import '../memoryGameStyle/card.css';
class Card extends React.Component{
constructor(props){
super(props);
const {hidden,show,id,r,g,b}=this.props.card
this.state={...}
const style='';
}
componentWillReceiveProps(){...}
onClick=()=>{
const {id}=this.props.card
this.setState({hidden:false})
this.setState({show:true})
const cards=this.props.cards.map((card,i)=>{
console.log(card)
})
}
render(){...}
이 오류 당신이 보내는
아, 이제 8 시간 더 고맙습니다. 고맙습니다. 답변을 수락 할 수 있습니다. – Nhat
멋진 소리입니다! –