Skip to content

Instantly share code, notes, and snippets.

@mikekoro
Last active May 9, 2020 05:55
Show Gist options
  • Save mikekoro/483664764fd0d7806ade27a6379e61c6 to your computer and use it in GitHub Desktop.
Save mikekoro/483664764fd0d7806ade27a6379e61c6 to your computer and use it in GitHub Desktop.
// LoginPage.js
import React from 'react';
import { LoginForm } from 'LoginForm';
import { useValue } from 'useValue';
export default function LoginPage() {
const { value, assignValue } = useValue(false); // Calling our custom hook; false is the initial value this time around
function handleSubmit() {
assignValue(true);
}
return (
<div>
<h3>Login Form</h3>
{
value ?
<div data-testid="submitted-state">Submitted</div> :
<div data-testid="submitted-state">Not Submitted</div>
}
<LoginForm handleSubmit={(e) => handleSubmit(e)}/>
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment