Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/464.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 类型为“boolean”的属性“function”无效`_Javascript_Reactjs_React Native_Eslint - Fatal编程技术网

Javascript 类型为“boolean”的属性“function”无效`

Javascript 类型为“boolean”的属性“function”无效`,javascript,reactjs,react-native,eslint,Javascript,Reactjs,React Native,Eslint,我试图将一个函数从一个JavaScript文件传递到一个组件 <Button onPress={() => console.log(title)} /> const Button = ({ onPress }) => { const { buttonStyle, buttonTextStyle } = styles; return ( <TouchableOpacity onPress{...onPress} style={buttonStyle}>

我试图将一个函数从一个JavaScript文件传递到一个组件

<Button onPress={() => console.log(title)} />
const Button = ({ onPress }) => {
const { buttonStyle,
buttonTextStyle } = styles;

return (
    <TouchableOpacity onPress{...onPress} style={buttonStyle}>
        <Text style={buttonTextStyle}>Click Me!!</Text>  
    </TouchableOpacity>
);
})

每次我没有将
放入onPress功能时,我都会收到以下错误:

分析错误:意外标记,应为
..


我是新来的本地人,已经调试了一个小时了。被我做错了什么难倒了。我不明白为什么代码认为函数是布尔类型。作为参考,我正在使用ESLint和扩展。

onPress
接受您在道具中传递的函数。只需引用已分解的属性。另外,在
onPress
属性中缺少
=

<TouchableOpacity onPress={onPress} style={buttonStyle}>


您缺少作业
onPress={onPress}
我很高兴能为您提供帮助,如果问题确实解决了您的问题,请将问题标记为已回答,谢谢