簡體   English   中英

React-native中asyncStorage的Formik提交問題

[英]Formik submission problem with asyncStorage in react-native

我有兩個用於formik登錄的輸入組件:

 <View>
      <TextField
        style={{color: 'white'}}
        label={label}
        tintColor={formikProps.touched[formikKey] && formikProps.errors[formikKey] ? 'red' : 'white'}
        onChangeText={e => formikProps.setFieldValue(formikKey, e)}
        onBlur={formikProps.handleBlur(formikKey)}
        {...rest}
      />
      <Text style={{color: 'red'}}>
        {formikProps.touched[formikKey] && formikProps.errors[formikKey]}
      </Text>
    </View> . 

然后,我有一個使用formik登錄的表單:

{formikProps => (
          <View style={styles.container}>
            <HeaderWithLogo source={Logo.docaBlack} style={styles.header} />
            <View style={styles.subContainer}>
              <Animatable.View animation="slideInRight">
                <InputWithMessage
                  label="Email"
                  formikProps={formikProps}
                  formikKey="email"
                  value={formikProps.values.email || email}
                  placeholder="dukekaboum@example.com"
                  autoFocus
                />
              </Animatable.View>
              <Animatable.View animation="slideInRight" delay={800}>
                <InputWithMessage
                  label="Mot de passe"
                  formikProps={formikProps}
                  value={formikProps.values.password || password}
                  formikKey="password"
                  placeholder="mot de passe"
                  secureTextEntry
                />

成功登錄后,我使用asyncStorage來存儲電子郵件和密碼。 當我重新加載loginScreen時,當我想重新登錄時,我的郵件輸入和密碼輸入的值將設置為我的存儲BUT的值,yup和formik對我說沒有郵件值,也沒有傳遞值...。

aw可以很好地使用asyncStorage和formik?

好的,解決方法是: intialValues之前的enableReinitialize

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM