-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
step3 - creates the SimpleForm component
- Loading branch information
Carlos Junior
committed
Mar 19, 2020
1 parent
8d99afa
commit ae58797
Showing
5 changed files
with
336 additions
and
218 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
import React from "react"; | ||
import "./styles.css"; | ||
import React from 'react'; | ||
import './styles.css'; | ||
|
||
export default function App() { | ||
return ( | ||
<div className="App"> | ||
<h1>Hello CodeSandbox</h1> | ||
<h2>Start editing to see some magic happen!</h2> | ||
</div> | ||
); | ||
} | ||
import SimpleForm from './components/SimpleForm'; | ||
|
||
const App = () => <SimpleForm />; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { useState } from 'react'; | ||
|
||
const SimpleForm = () => { | ||
const [name, setName] = useState(''); | ||
|
||
const handleSubmit = e => e.preventDefault(); | ||
|
||
return ( | ||
<form onSubmit={handleSubmit}> | ||
<div> | ||
<label htmlFor="name">name</label> | ||
<input | ||
type="text" | ||
name="name" | ||
id="name" | ||
value={name} | ||
onChange={e => setName(e.target.value)} | ||
/> | ||
</div> | ||
</form> | ||
); | ||
}; | ||
|
||
export default SimpleForm; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
|
||
import SimpleForm from './SimpleForm'; | ||
|
||
describe('<SimpleForm />', () => { | ||
it('should render a name input', () => { | ||
const { getByLabelText } = render(<SimpleForm />); | ||
|
||
const nameInput = getByLabelText('name'); | ||
|
||
expect(nameInput).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.