我收到错误" Uncaught TypeError:listener必须是一个函数" 我不知道自己做错了什么。我花了很多时间在这上面,但没有到达任何地方。
componentDidMount() {
// Called after react has rendered the HTML in the DOM.
AppStore.addChangeListener(this.handleChange);
console.log(AppStore.addChangeListener(this.handleChange));
}
handleChange() {
debugger;
this.forceUpdate();
}
我的组件看起来像这样
public class ConnectThread extends Thread{
private BluetoothSocket bTSocket;
public boolean connect(BluetoothDevice bTDevice, UUID mUUID) {
BluetoothSocket temp = null;
try {
temp = bTDevice.createRfcommSocketToServiceRecord(mUUID);
} catch (IOException e) {
Log.d("CONNECTTHREAD","Could not create RFCOMM socket:" + e.toString());
return false;
}
try {
bTSocket.connect();
} catch(IOException e) {
Log.d("CONNECTTHREAD","Could not connect: " + e.toString());
try {
bTSocket.close();
} catch(IOException close) {
Log.d("CONNECTTHREAD", "Could not close connection:" + e.toString());
return false;
}
}
return true;
}
public boolean cancel() {
try {
bTSocket.close();
} catch(IOException e) {
Log.d("CONNECTTHREAD","Could not close connection:" + e.toString());
return false;
}
return true;
}
}