Reputation: 4928
Please , am having some error that is proving diffcult to fix for me. I have a simple react component below
import React from 'react';
const ForumPostComponent = (topics) => {
const {forums} = topics;
return (
forums.toJS().map((forum, key) => {
console.log(forum);
return (
<div className="post" key={key}>
)
})
)
}
In another component, i used my react forumComponent like .
<ForumPostComponent forums={this.props.forums.get('forums')} />
It throws the error in the title. Also My console message in the forum component returns values . I tried and read many similar questions all to no aveil. Please what exactly am i missing.?
Upvotes: 2
Views: 640
Reputation: 51851
Array is not valid react element, you need to wrap with some container. E.g. <div>
:
return (
<div>
{forums.toJS().map((forum, key) => {
console.log(forum);
return (
<div className="post" key={key} />
)
})}
</div>
)
Furthermore using array indexes as elements keys is a bad practice. You should use some business keys instead.
Upvotes: 3