In my react app, I am trying to use a Cordova plugin (cordovo-plugin-device) to get user's device version as follows
class LogoHeader extends React.Component {
componentDidMount () {
window.addEventListener('deviceready', this.onDeviceReady)
}
onDeviceReady () {
console.log(device.cordova)
}
render () {
...
}
}
But for some reason, the deviceready
event never gets fired. Am I missing something? Is there a better way to listen to DOM events in react ?