Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.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
React native 包含箭头的函数捕获';这';用打字稿_React Native - Fatal编程技术网

React native 包含箭头的函数捕获';这';用打字稿

React native 包含箭头的函数捕获';这';用打字稿,react-native,React Native,我正在将JavaScript代码转换为Typescript。以前我有一个建设者,但现在他返回这个错误给我,我不知道如何解决它 这是我的screen.tsx文件 错误: “包含箭头的函数捕获“this”的全局值” const styles=StyleSheet.create({ //----我的风格---- }); 常量签名:React.FC=()=>{ const{signed,signIn,user}=useContext(AuthContext); 控制台日志(签名); console.lo

我正在将JavaScript代码转换为Typescript。以前我有一个建设者,但现在他返回这个错误给我,我不知道如何解决它

这是我的screen.tsx文件

错误:

“包含箭头的函数捕获“this”的全局值”

const styles=StyleSheet.create({
//----我的风格----
});
常量签名:React.FC=()=>{
const{signed,signIn,user}=useContext(AuthContext);
控制台日志(签名);
console.log(用户);
函数handleSign(){
签名();
}
返回(
登录
进入
使用者
this.textInputChange(text)}
/>
{this.state.check\u textInputChange?
:null}
);
};
导出默认签名;
TLDR 在功能组件中,没有
。在功能部件
处,此
是全局的

答复 在
类组件中有这个,但是
功能组件中没有这个。
您可以在两者之间搜索不同的内容。

我是说这个TLDR 在功能组件中,没有
。在功能部件
处,此
是全局的

答复 在
类组件中有这个,但是
功能组件中没有这个。
您可以在两者之间搜索不同的内容。


我是说,我能查一下你的全班代码吗?我不明白这个代码有什么问题,我可以检查一下你的完整类代码吗?我不明白这个代码有什么问题对不起,你能更好地解释一下你的解决方案吗?(我明白了。)我希望我能对你有所帮助。你对某个州是什么意思?在我的系统中,它返回一个错误状态。我认为你需要研究什么是
状态
,什么是
状态
,有些状态可以是你想用的状态对不起,你能更好地解释你的解决方案吗?(我明白了。)我希望我能对你有所帮助。你对某个州是什么意思?在我的系统中,它返回一个错误状态。我认为你需要研究什么是
状态
,什么是
状态
,有些状态可以是你想用的
const styles = StyleSheet.create({
    //----My styles----
});


const SignIn: React.FC = () => {
    const { signed, signIn, user } = useContext(AuthContext);

    console.log(signed);
    console.log(user);

    function handleSign() {
        signIn();
    }
    

    return (
        <ScrollView contentContainer={{ flex: 1 }} showsVerticalScrollIndicator={false}>
            <View style={styles.container}>
                <StatusBar barStyle="light-content" />
                <View style={styles.header}>
                    <Text style={styles.text_header}>Sign in</Text>
                    <Text style={styles.text_header_bottom}>Enter</Text>
                </View>

                <Animatable.View
                    animation="fadeInUpBig"
                    style={styles.footer}>
                    <Text style={styles.text_footer}>User</Text>
                        <View style={styles.action}>
                            <FontAwesome
                                name="user-o"
                                color="#000"
                                size={20} />
                            <TextInput
                                placeholder="username"
                                style={styles.textInput}
                                onChangeText={(text) => this.textInputChange(text)}
                            />
                            {this.state.check_textInputChange ?
                                <Animatable.View
                                    animation="bounceIn">
                                    <Feather
                                        name="check-circle"
                                        color="green"
                                        size={20}
                                    />
                                </Animatable.View>
                                : null}
                        </View>
                        
                </Animatable.View>
            </View>
        </ScrollView>
    );
};

export default SignIn;