Javascript 在React with ES6中映射对象内的数组

Javascript 在React with ES6中映射对象内的数组,javascript,arrays,json,reactjs,lodash,Javascript,Arrays,Json,Reactjs,Lodash,我正在制作一个react feed应用程序,灵感来自(还有),我在尝试使用函数将数组作为道具传递到数组中时遇到了一些问题。这是我正在映射的信息: const events = [ { event: 'Gods', venue: 'Asgard', venuePicture: 'picture1.jpg',

我正在制作一个react feed应用程序,灵感来自(还有),我在尝试使用函数将数组作为道具传递到数组中时遇到了一些问题。这是我正在映射的信息:

const events = [ 
                {
                    event: 'Gods',
                    venue: 'Asgard',
                    venuePicture: 'picture1.jpg',
                    when: '21:00 27/04/16',
                    genres: ['rock', 'funk'],
                    artists: [
                        {
                            artist: 'Thor',
                            artistPicture: 'thor.jpg'
                        },

                        {
                            artist: 'Loki',
                            artistPicture: 'loki.jpg'
                        }
                    ]

                },

                {
                    event: 'Humans',
                    venue: 'Midgard',
                    venuePicture: 'picture2.jpg',
                    when: '21:00 27/04/16',
                    genres: ['jazz', 'pop'],
                    artists: [
                        {
                            artist: 'Human1',
                            artistPicture: 'human1.jpg'
                        },

                        {
                            artist: 'Human2',
                            artistPicture: 'human2.jpg'
                        }
                    ]

                }


             ];
我像这样传递到组件(这是有效的):

等等


我看到这里有一个模式,我只是不知道如何进一步实现它。当我尝试重复相同的分解结构时,它会中断,然后u.map。有人能帮我一下吗,很抱歉发了这么长的帖子。

哦,我发现了这个问题,多亏了的评论(他删除了他的评论),它在这里:

const { event, venue, venuePicture, when, genres, artists } = this.props.events;
    _.map({artists}, (artist, index) => <ItemArtist key={index} {...artist} {...props}/>);
const{event,venue,picture,when,tyres,artist}=this.props.events;
_.map({artists},(artist,index)=>);
“艺术家”不应该被分解(花括号),应该是这样的:

renderArtists() {

        const { event, venue, venuePicture, when, genres, artists } = this.props.events;

        const props = _.omit(this.props, 'events');
        return  _.map({artists}, (artist, index) => <ItemArtist key={index} {...artist} {...props}/>);

    }

    render() {
        return (
            <ul>
                {this.renderArtists()}
            </ul>
        );
    }
_.map(artists, (artist, index) => <ItemArtist key={index} {...artist} {...props}/>);
地图(艺术家,(艺术家,索引)=>);
非常感谢你们

return(this.props.events).flatMap('artists').map((artist,index)=>).value();
return _(this.props.events).flatMap('artists').map((artist, index)=><ItemArtist key={index} {...artist} {...props}/>).value();

使用
怎么样?获取
?我想这会有用的,你能把它上传到jsbin或者其他我们可以测试它的好地方吗?你的第一条评论(你删除的那条)解决了我的问题VyvIT,非常感谢!我不敢相信我花了这么多时间,但我没有注意到:DNo问题,这里有一个解决方案,可以从初始事件数组中平面映射艺术家。
_.map(artists, (artist, index) => <ItemArtist key={index} {...artist} {...props}/>);
return _(this.props.events).flatMap('artists').map((artist, index)=><ItemArtist key={index} {...artist} {...props}/>).value();