我想从HelloWorldApp函数内部调用snapShotTaker函数,但是在终端得到ERROR TypeError: undefined is not a function, js engine: hermes
,这个问题怎么解决?
notifee.registerForegroundService(notification => {
return new Promise(() => {
// Long running task...
setInterval(() => {
HelloWorldApp.snapShotTaker();
}, 2000);
});
});
const HelloWorldApp = () => {
const isAppForeground = useIsForeground();
console.log('In Foreground?: ', isAppForeground);
const cameraRef = useRef(null);
const [finalPath, setPhotoPath] = useState('');
const devices = useCameraDevices();
const device = devices.front;
if (device == null) {
return <ActivityIndicator style={styles.indicator} size="large" />;
}
const snapShotTaker = async () => {
const snapshot = await cameraRef.current.takeSnapshot({
quality: 20,
skipMetadata: true,
});
setPhotoPath('file://' + snapshot.path);
};
1条答案
按热度按时间ifmq2ha21#
你不能在组件外部调用它,但是你可以使用useEffect hook把notifee代码移到你的组件内部并在那里调用它。