attempting to programmatically disconnect from a socket.io connection once the nav-bar back button is pressed.
I've tried handling button presses according to Wix GitHub documentation here: https://wix.github.io/react-native-navigation/#/docs/topBar-buttons?id=handling-button-press-events
export default class Lobby extends React.Component {
static options(passProps) {
return {
topBar: {
leftButtons: {
id: "backButton"
}
}
};
}
constructor(props) {
super(props);
this.state = {
username: "",
queue: []
};
Navigation.events().bindComponent(this);
}
// for the parameter I've tried: `{buttonId}`, `{backButton}`,`"backButton"`, `backButton`
navigationButtonPressed(backButton) {
const socket = io("http://172.31.99.250:3000");
socket.emit("leaveLobby", this.state.username);
}
Nothing from the handler function happens. the Apps just goes back to the previous page without sending the socket.io event