【发布时间】:2017-08-28 18:42:25
【问题描述】:
我有一个播放列表,我正在尝试将 keyDown 绑定到.. 问题是我无法使用典型的 React.Component,因为我正在使用一个需要我使用功能性无状态的库 (https://github.com/clauderic/react-sortable-hoc)组件(可排序容器)。所以我什至无法访问道具或状态。我试图将数据作为参数传递,但没有任何效果..
这可行,但我需要以某种方式将数据传递给 handleKeyDown.. 特别是我真的想以某种方式将“道具”传递给 handleKeyDown
function handleKeyDown(e) {
// **** I need some way to access outside data in here some how..
// whether it's passed as a parameter or any other way
console.log(e.keyCode);
}
const PlaylistPages = SortableContainer(( props ) => {
return (
<div className="playlist-sortable" onKeyDown={handleKeyDown} tabIndex="0">
// etc
);
}
【问题讨论】:
标签: javascript reactjs redux react-redux