警告:propType失败:提供给`ListItem`的无效prop`child`,期望一个ReactNode

时间:2016-05-11 08:30:52

标签: reactjs firebase lodash

我构建了一个应用程序以及教程“聊天应用程序。使用React,Flux,Firebase和Webpack构建实时应用程序”,我遇到了一个我无法处理的问题。基本上我尝试将我在Firebase中设置的频道拉到我在React的商店但是出了点问题。这是代码的错误部分:

import alt from '../alt/index.js';
import Actions from '../actions/index.js';
import {decorate, bind, datasource} from 'alt-utils/lib/decorators';
import ChannelSource from '../sources/ChannelSource.jsx';
import _ from 'lodash';

@datasource(ChannelSource)
@decorate(alt)
class ChatStore {
constructor(){
 this.state = {user: null};
}

@bind(Actions.channelsReceived)
receivedChannels(channels){
let selectedChannel;
_(channels)
  .keys()
  .map((key, index) =>{
    channels[key].key = key;
    if (index == 0){
      channels[key].selected = true;
      selectedChannel = channels[key];
    }
  })
  .value();
console.log(channels);

this.setState({
  channels,
  selectedChannel
});
}
}

 export default alt.createStore(ChatStore);

在教程中使用了函数链:keys().each().value()来拉取通道,但在我的应用程序中它没有用完所以我尝试使用.map()而不是.each(),但它没有也工作。

浏览器显示与此部分代码相关的警告和错误:

警告:propType失败:提供给children的无效道具ListItem,预期是ReactNode。检查Channel的呈现方法。 ListItem的'children'只是从Firebase中提取的频道。

以下是与此问题相关的错误:  未捕获(在承诺中)错误:对象无效作为React子对象(找到:具有键{name,key,selected}的对象)。如果您要渲染子集合,请使用数组,或使用React附加组件中的createFragment(object)包装对象。检查ListItem的呈现方法。

我尝试了所有东西,但我堆积在这里,无法继续前进。谢谢你的帮助。

0 个答案:

没有答案
相关问题