2
我有一个范围问题,我正在努力解决。React.createClass中的范围问题
我将getTrackNotes导入到es6模块中,并且我想根据下面的内容在React类中引用它,但是这设置为Track(React类)。
我该如何参考?
import { getTrackNotes } from '../utils/immutableInstruments';
const Track = React.createClass({
componentDidMount() {
const { trackId } = this.props.params;
function updateTimeSequencer (socket, state, getTrackNotes, TimeSequencer, instruments, trackId)
{
//I want to call getTrackNotes here, but the scope is set to the Track React class
**getTrackNotes();**
}
var instruments = this.props.instruments;
socket.on('state', updateTimeSequencer.bind(this, socket));
}
啊,我想知道这到底是怎么回事,我想试试谢谢 – iKode