react-native - React Native 与 expo 错误:useEffect 只读
问题描述
我尝试了两个步骤,我得到了同样的错误(useEffect read-only
):
const requestPermission = async ()=> {
const {granted}= await ImagePicker.requestCameraRollPermissionsAsync;
if(!granted)
alert('You have to enable permission to access photos');
};
useEffect =(()=> {
requestPermission();
},[])
第二种方法是
useEffect =(()=> {
const request = async ()=>{
const {granted}= await ImagePicker.requestCameraRollPermissionsAsync;
if(!granted)
alert('You have to enable permission to access photos');
};
},[])
先感谢您。
解决方案
您的通话中有一个=
标志(就在 之后),这使得您看起来像是在分配某些东西useEffect
useEffect
useEffect
编辑:
useEffect(() => {
requestPermission();
}, [])
您必须以相同的方式编辑您的其他呼叫。
推荐阅读
- angular - 将自定义多行 HTML 内容添加到 Angular 材料表中的 MatCell
- c# - 游戏 AI 如何统一定位、识别和瞄准其他游戏对象
- c# - NuGet 包无法在 .NET Core 中安装,但可以在 .Net Framework 中运行。为什么?
- windows - 错误:Windows 和 wamp 不支持的 DB 驱动程序
- mysql - 使用变量忽略顺序模拟 row_number
- excel - 在 Excel 中自动运行的宏
- ios - 如何将混合形状 SCNNode 居中以查看
- jenkins - 在管道的容器步骤中使用时,环境变量值中的“$”字符加倍
- javascript - ESLint 不能在 PyCharm 中运行 HTML 文件
- html - 列之间的 css 空间