반응 구성 요소가 있습니다. 예를 들어 component_1
이라고합시다. 그리고 내 배열은 형태로되어 있습니다. array_list =
[{}, {}, {}, {}]과 같이 말합니다. 배열의 다중 반응 구성 요소 렌더링
import component_1 from 'component_1'
import array_list from 'array_list'
class component_2 extends Component{
constructor(props){
super(props)
}
render(){
const {renderMenu} = this.props
var contentData = [];
array_list.forEach(function(item, index, array){
contentData.push(<component_1 {...item} />);
});
return(
<div>
<div className="ui four column centered grid">
{contentData}
</div>
</div>
)
}
}
export default component_2
동안, 그것은 일반적으로 다른 HTML 요소와 함께 작동합니다. 여기에 오류가 발생합니다 :
React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of `OnBoardingContentElement`
반응 구성 요소의 배열을 이렇게 변환 할 수 있습니까? 그렇지 않다면, 이것에 대한 회피 접근법이 있습니까?
어떤 import 문을 사용합니까? 나는 당신이 array_list에 대해서 이야기하고 있다고 가정하고 있습니다. 그렇습니다. 그렇다면 대답은 아니오입니다. 작동하지 않을 것입니다. 그것은 단지 sudo-code입니다. 함수 내부에 array_list를 생성하고 있습니다. – nitte93user3232918
아니요, 구성 요소를 가져옵니다. createElement가 null에 대해 불평하면 컴포넌트가 제대로 임포트되지 않은 것처럼 들립니다. – John