how to get device id in react native. I am using create react native not android studio. I am new to this.
import DeviceInfo from 'react-native-device-info';
constructor(props) {
super(props);
this.state = { id: '' }
this.onNavigateTo = this.onNavigateTo.bind(this);
}
componentDidMount() {
this.setState({id: DeviceInfo.getUniqueID()}, () =>
alert(this.state.id));
}
render() {
return (
<Text>{this.state.id}</Text>
);
}
Error: undefined is not an object (evaluating 'RNDevice.uniqueId')
Note:- I am not using run-android or run-ios
I am using Create-react-native app and yarn start. The output will be on device through Expo app