Redux搜索“.get()不是函数”

时间:2016-03-03 11:40:32

标签: javascript redux immutable.js

在“videos.json”中我有:

[
  { "id":"1", "name":"hotfuzz cover", "category":"music", "rating":"100" },
  { "id":"2", "name":"photos by me", "category":"photos", "rating":"78" },  
  { "id":"4", "name":"my backstreetboys cover", "category":"music","rating":"13"},
  { "id":"5", "name":"my crazy salsa skills", "category":"dance", "rating":"90" },
  { "id":"6", "name":"stand up show", "category":"comedy", "rating":"42" }
]

=============================================== ========================

在core.js

export function setVideos(state, videos) {

  const list = List(videos);  
  return state.set('videos', list)

}

1.问题:我想在状态中设置“名称”,就像我设置视频一样。使用immutablejs有一个简短的方法吗?我无法在没有制图的情况下达到身份证,姓名,类别,评级

=============================================== ==========================

export function isPartialMatch(text, textItem) {
    return text.toLowerCase().indexOf(textItem.toLowerCase()) !== -1;
}


export function searchItems(state, textItem) {

  const videos= state.get('videos');

  const newName = videos.filter(item => isPartialMatch(item.get('name'), textItem));

  return state.set('videos', newVideos);
}

=============================================== ========================== 在Filters.jsx中  内部反应渲染功能我有;

<div>    
        <input
          type="text"
          className="searchBar"
          placeholder="Search by name..."
          style={({
            marginBottom: '0.5em'
          })}
          onChange={event => this.props.searchItems(event.target.value) }
        />
  </div>

=============================================== ==========================

2.问题:我正在尝试搜索名称(textItem是文本输入)。但我得到“item.get不是函数”错误。我怎样才能搜索姓名?感谢您的帮助

0 个答案:

没有答案