expo: Camera stopped working on web
Summary
Just trying to run the demo snack from here now throws the following error:
https://capture.dropbox.com/cqTOieM2WOyuiJb0?src=ss

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!
managed
What platform(s) does this occur on?
Web
SDK Version (managed workflow only)
44.0.5
Environment
Expo CLI 5.0.3 environment info: System: OS: macOS 12.1 Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.1/bin/yarn npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7935034 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild npmPackages: @expo/webpack-config: ~0.16.2 => 0.16.16 expo: ^44.0.5 => 44.0.5 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 npmGlobalPackages: expo-cli: 5.0.3 Expo Workflow: managed
Reproducible demo
import React, { useState, useEffect } from 'react';
import { StyleSheet, Text, View, TouchableOpacity } from 'react-native';
import { Camera } from 'expo-camera';
export default function App() {
const [hasPermission, setHasPermission] = useState(null);
const [type, setType] = useState(Camera.Constants.Type.back);
useEffect(() => {
(async () => {
const { status } = await Camera.requestCameraPermissionsAsync();
setHasPermission(status === 'granted');
})();
}, []);
if (hasPermission === null) {
return <View />;
}
if (hasPermission === false) {
return <Text>No access to camera</Text>;
}
return (
<View style={styles.container}>
<Camera style={styles.camera} type={type}>
<View style={styles.buttonContainer}>
<TouchableOpacity
style={styles.button}
onPress={() => {
setType(
type === Camera.Constants.Type.back
? Camera.Constants.Type.front
: Camera.Constants.Type.back
);
}}>
<Text style={styles.text}> Flip </Text>
</TouchableOpacity>
</View>
</Camera>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
camera: {
flex: 1,
},
buttonContainer: {
flex: 1,
backgroundColor: 'transparent',
flexDirection: 'row',
margin: 20,
},
button: {
flex: 0.1,
alignSelf: 'flex-end',
alignItems: 'center',
},
text: {
fontSize: 18,
color: 'white',
},
});
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (3 by maintainers)
We have the same issue. We identified that for some reason the
@kolae/useworkerpackage is installing react@16 although all the rest is react@17. If we deleterm -rf node_modules/expo-camera/node_modules/reactit works.please see the output of
npm ls -anpm.txtour quick fix is to add
"postinstall": "rm -rf node_modules/expo-camera/node_modules/react"Hi everyone,
I am experiencing the same issue. I just created a brand-new expo project and copied the example from expo-camera page. It gives me the same error (hooks), and works ok on iOS.
Also my old projects with camera continue to work. The only notable thing I have done recently is upgraded expo-cli to the latest version (5.3.0), but I don’t see how it can be an issue.
You can fix this by using the “override” feature of package.json (of your App). Works like a charm. This example forces every sub dependency to use React 18 regardless what they describe in their package.json. Hope it helps. Peace 🤍
Still getting this error, while upgrading to “react”: “^18.2.0”, “react-native”: “^0.71.0”, “expo”: “^47.0.13”, “expo-camera”: “~13.1.0”
tried: “postinstall”: “rm -rf node_modules/expo-camera/node_modules/react”
Yes it worked after the restart. Thank you!