This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App() { | |
return ( | |
<div className="App"> | |
... | |
</div> | |
); | |
} | |
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Greetings = ({ firstName }) => ( | |
<div>Hi, {firstName}</div> | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { compose, pure } from "recompose"; | |
... | |
export default compose( | |
pure, | |
withFormLogic | |
)(SignupForm); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { TextField, Button, Grid } from "@material-ui/core"; | |
import withFormLogic from "./logic"; | |
const SignupForm = ({ | |
email, onChangeEmail, emailError, | |
password, onChangePassword, passwordError, | |
confirmPassword, onChangeConfirmPassword, confirmPasswordError, | |
onSubmit | |
}) => ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { compose } from "recompose"; | |
import withTextFieldState from "./withTextFieldState"; | |
import withEmailError from "./withEmailError"; | |
import withPasswordError from "./withPasswordError"; | |
import withConfirmPasswordError from "./withConfirmPasswordError"; | |
import withSubmitForm from "./withSubmitForm"; | |
export default compose( | |
withTextFieldState, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { withHandlers } from "recompose"; | |
import axios from "axios"; | |
const handleSubmit = ({ | |
email, | |
password, | |
emailError, | |
passwordError, | |
confirmPasswordError | |
}) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { withProps } from "recompose"; | |
const getConfirmPasswordError = (password, confirmPassword) => { | |
if (!confirmPassword.isDirty) { | |
return ""; | |
} | |
const passwordsMatch = password.value === confirmPassword.value; | |
return !passwordsMatch ? "Passwords don't match." : ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { withProps } from "recompose"; | |
const getPasswordError = password => { | |
if (!password.isDirty) { | |
return ""; | |
} | |
const passwordRegex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/; | |
const isValidPassword = passwordRegex.test(password.value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { withProps } from "recompose"; | |
const getEmailError = email => { | |
if (!email.isDirty) { | |
return ""; | |
} | |
const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
const isValidEmail = emailRegex.test(email.value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { withStateHandlers, compose } from "recompose"; | |
const initialState = { | |
email: { value: "" }, | |
password: { value: "" }, | |
confirmPassword: { value: "" } | |
}; | |
const onChangeEmail = props => event => ({ | |
email: { |