I follow the setting and code with rn-apple-healthkit's document
However I got a strange mistake !!
Anyone have the answer?
`import React, { Component } from 'react';
import {
ScrollView,
Navigator,
View,
NativeAppEventEmitter,
} from 'react-native';
import axios from 'axios';
import AppleHealthKit from 'rn-apple-healthkit';
import AlbumDetail from './AlbumDetail';
const d = new Date();
const PERMS = AppleHealthKit.Constants.Permissions;
const HKOPTIONS = {
permissions: {
read: [
PERMS.StepCount,
PERMS.Height,
PERMS.Weight,
PERMS.DateOfBirth,
PERMS.BodyMassIndex,
],
write: [
PERMS.StepCount,
PERMS.Weight,
PERMS.BodyMassIndex,
],
},
date: d.toISOString()
};
AppleHealthKit.initHealthKit(HKOPTIONS, (err, res) => {
if (err) {
console.log('HealthkitInitError: ', err);
return;
}
console.log('HealthkitInitSucess');
AppleHealthKit.initStepCountObserver({}, () => {});
this.sub = NativeAppEventEmitter.addListener(
'change:steps',
(event) => {
// mistake is here!!!
this._fetchStepCountData();
console.log(event);
}
);
});
// StepCounter Example
AppleHealthKit.getStepCount(HKOPTIONS, (error, results) => {
if (error) {
console.log('getStepCountError: ', error);
return;
}
console.log(results);
});
class albumList extends Component {
state = { albums: [] };
componentWillMount() {
axios.get('https://rallycoding.herokuapp.com/api/music_albums')
.then(response => this.setState({ albums: response.data }))
.then(response => console.log(response));
}
componentDidMount() {
console.log(this.state.albums);
}
// when the component where the listener was added unmounts, call the 'remove' method of the subscription object.
componentWillUnmount() {
this.sub.remove();
};
renderAlbums() {
return this.state.albums.map(album =>
);
}
render() {
return (
{this.renderAlbums()}
);
}
}
export default albumList;`