Пытался найти способ исправить мою проблему, но все еще не могу понять.
Я использовал Formik для регистрации, и я хочу передать значение моей базе данных.
Я хочу чтобы получить что-то вроде этого (проверьте изображение) учетные данные аутентификации firebase
учебник, за которым я следую. https://www.youtube.com/watch?v=J_SEMZKFxtw 6:06 таймфрейм.
authActions. js
export const signUp = data => async (
dispatch,
getState,
{getFirebase}
) => {
const firebase = getFirebase()
try {
const res = await firebase
.auth()
.createUserWithEmailAndPassword(data.email, data.password);
console.log(res);
} catch(err) {}
};
signUp. js
import React from 'react';
import { connect } from 'react-redux';
import { Formik, Field } from 'formik';
import * as Yup from 'yup';
import { FormWrapper, StyledForm } from '../../../hoc/layout/elements';
import Input from '../../../components/UI/Forms/Input/Input';
import Button from '../../../components/UI/Forms/Button/Button';
import Heading from '../../../components/UI/Headings/Heading';
import * as actions from '../../../store/actions';
const SignUpSchema = Yup.object().shape({
firstName: Yup.string()
.required('Your first name is required')
.min(3, 'Too short.')
.max(25, 'Too long.'),
lastName: Yup.string()
.required('Your last name is required')
.min(3, 'Too short.')
.max(25, 'Too long.'),
email: Yup.string()
.email('Invalid email.')
.required('The email is required.'),
password: Yup.string().required('The password is required.').min(8, 'The password is too short'),
confirmPassword: Yup.string()
.oneOf([Yup.ref('password'), null], `Password doesn't match`)
.required('You need to confirm your password.'),
})
const SignUp = ({ signUp }) => {
return (
<Formik
initialValues={{
firstName: '',
lastName: '',
email: '',
password: '',
confirmPassword: ''
}}
validationSchema={SignUpSchema}
onSubmit={(values, { setSubmitting }) => {
console.log(values);
signUp(values)
setSubmitting(false)
}}
>
{({isSubmitting, isValid}) => (
<FormWrapper>
<Heading size="h1" color="white" noMargin>Sign up for an account</Heading>
<Heading size="h4" color="white">Fill in your details to register your new account</Heading>
<StyledForm>
<Field type='text' name='firstName' placeholder="Your first name" component={Input} />
<Field type='text' name='lastName' placeholder="Your last name" component={Input} />
<Field type='email' name='email' placeholder="Your email..." component={Input} />
<Field
type='password'
name='password'
placeholder="Your password..."
component={Input}
/>
<Field
type='password'
name='confirmPassword'
placeholder="Re-type your password..."
component={Input}
/>
<Button disabled={!isValid} type="submit">Sign up</Button>
</StyledForm>
</FormWrapper>
)}
</Formik>
);
};
const mapStateToProps = (state) => ({
})
const mapDispatchToProps = {
signUp: actions.signUp,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(SignUp);
. / действия / указатель. js
export { signUp } from './authActions';