React native 如何将redux表单与redux persist一起使用?

React native 如何将redux表单与redux persist一起使用?,react-native,persistent,react-redux-form,React Native,Persistent,React Redux Form,我的代码运行得非常好。我需要一些帮助来修改我的代码,以便它能够持久地存储数据(刷新表单后,表单应该填充用户输入的相同数据)。App.js中要修改的部分是dispatcher和store.js。欢迎提供任何帮助或合乎逻辑的建议。提前谢谢。 这是我的App.js const Form = (props) => { const { handleSubmit } = props; const onSubmit = (values) => console.log(values);

我的代码运行得非常好。我需要一些帮助来修改我的代码,以便它能够持久地存储数据(刷新表单后,表单应该填充用户输入的相同数据)。App.js中要修改的部分是dispatcher和store.js。欢迎提供任何帮助或合乎逻辑的建议。提前谢谢。 这是我的App.js

const Form = (props) => {
  const { handleSubmit } = props;
  const onSubmit = (values) => console.log(values);
  const renderInput = ({ input: { onChange, ...input }, ...rest}) => {
    return <TextInput style={styles.input} onChangeText={onChange} {...input} {...rest} />
  };

  return (
    <View style={styles.root}>
      <Field
        name={'email'}
        props={{
          placeholder: 'Email'
        }}
        component={renderInput}
      />
      <Field
        name={'password'}
        props={{
          placeholder: 'Password',
          secureTextEntry: true
        }}
        component={renderInput}
      />
      <Button title={'Submit'} onPress={handleSubmit(onSubmit)} />
    </View>
  );
};

const mapStateToProps = state => {
  return {
    email: state.email,
    password: state.password
  }
};

const mapDispatchToProps = (dispatch) => {
    return {
        fetchUserEmail: () => dispatch(email()),
        fetchPassword: () => dispatch(password()),
   };
};
export default reduxForm({form: 'test-form', destroyOnUnmount: false})(Form);
import {combineReducers, createStore, applyMiddleware} from 'redux';
import {reducer as formReducer} from 'redux-form';
import AsyncStorage from '@react-native-community/async-storage';
import { createLogger } from 'redux-logger';
import { persistStore, persistReducer } from 'redux-persist';

const rootReducer = combineReducers({
  form: formReducer,
  
});

const store = createStore(rootReducer);

export default store;