App.jsx
我有以下功能:
import { Position } from "./Position";
...
getPositionData = val => {
const { players } = this.props;
var res = players.filter(o=>Object.values(o).includes(val))
return res
};
正在处理
render()
<div>
,如下所示:
<div className="field-row">
{this.getPlayersByPosition(players, 4).map((player,i) => (
<Position key={i} handleClick={this.getPositionData}>{player.name}</Position>
))}
</div>
Position.jsx
把手
onClick()
export const Position = props => (
<div
className={`position-wrapper ${
isManager(props.children) ? null : "field"
}`}
onClick={() => props.handleClick(props.children)}
>
{props.children}
</div>
);
但是现在我想处理第二个函数
<
单击,例如:
toggleFullScreen() {
this.setState({ fullScreen: !this.state.fullScreen });
}
我会自己通过,就像这样:
onClick={this.toggleFullScreen.bind(this)}
如何处理这两个功能
onClick()
<div className="field-row">
...
</div>
?