TypeError: null is not an object (evaluating '_nativeInterface.default.getPhotos') Cameraroll react native community
TypeError: null is not an object (evaluating '_nativeInterface.default.getPhotos') Cameraroll react native community
我在尝试从 cameroll 获取照片时遇到此错误 "TypeError: null is not an object (evaluating '_nativeInterface.default.getPhotos')"。我确保已获得 android 和 ios 的所有许可。为 ios 安装必要的 pods 并且库也被链接。在 git 和 Whosebug 上尝试了一堆建议,但仍然没有成功。
import {
View,
Text,
StyleSheet,
TouchableOpacity,
ActivityIndicator,
Image,
FlatList,
Dimensions,
} from 'react-native';
import CameraRoll from '@react-native-community/cameraroll';
class AvatarBioScreen extends PureComponent {
state = {
images: [],
loading: false,
selected: null,
hasNextPage: false,
endCursor: '',
firstQuery: true,
};
componentDidMount() {
this._getPhotos();
}
_getPhotos = async after => {
if (this.state.firstQuery) {
this.setState({loading: true});
}
const res = await CameraRoll.getPhotos({
first: 20,
after,
});
this.setState({
images: [...this.state.images, ...res.edges],
loading: false,
hasNextPage: res.page_info.has_next_page,
endCursor: res.page_info.end_cursor,
firstQuery: false,
});
console.log('====================================');
console.log('res', res);
console.log('====================================');
};
}```
你的代码很好。确保你 运行 pod install 因为模块找不到这个组件时会出现这个错误
我在尝试从 cameroll 获取照片时遇到此错误 "TypeError: null is not an object (evaluating '_nativeInterface.default.getPhotos')"。我确保已获得 android 和 ios 的所有许可。为 ios 安装必要的 pods 并且库也被链接。在 git 和 Whosebug 上尝试了一堆建议,但仍然没有成功。
import {
View,
Text,
StyleSheet,
TouchableOpacity,
ActivityIndicator,
Image,
FlatList,
Dimensions,
} from 'react-native';
import CameraRoll from '@react-native-community/cameraroll';
class AvatarBioScreen extends PureComponent {
state = {
images: [],
loading: false,
selected: null,
hasNextPage: false,
endCursor: '',
firstQuery: true,
};
componentDidMount() {
this._getPhotos();
}
_getPhotos = async after => {
if (this.state.firstQuery) {
this.setState({loading: true});
}
const res = await CameraRoll.getPhotos({
first: 20,
after,
});
this.setState({
images: [...this.state.images, ...res.edges],
loading: false,
hasNextPage: res.page_info.has_next_page,
endCursor: res.page_info.end_cursor,
firstQuery: false,
});
console.log('====================================');
console.log('res', res);
console.log('====================================');
};
}```
你的代码很好。确保你 运行 pod install 因为模块找不到这个组件时会出现这个错误