forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
249f408
commit c7d8ad3
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
fixtures/dom/src/components/fixtures/event-pooling/form.js
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,55 @@ | ||
import TestCase from '../../TestCase'; | ||
|
||
const React = window.React; | ||
|
||
class Form extends React.Component { | ||
state = { | ||
submits: 0, | ||
resets: 0, | ||
}; | ||
|
||
handleSubmit = event => { | ||
event.preventDefault(); | ||
this.setState(state => ({submits: state.submits + 1})); | ||
}; | ||
|
||
handleReset = event => { | ||
event.preventDefault(); | ||
this.setState(state => ({resets: state.resets + 1})); | ||
}; | ||
|
||
render() { | ||
const {submits, resets} = this.state; | ||
|
||
const formStyle = { | ||
padding: '10px 20px', | ||
border: '1px solid #d9d9d9', | ||
margin: '10px 0 20px', | ||
}; | ||
|
||
return ( | ||
<TestCase title="Form" description=""> | ||
<TestCase.Steps> | ||
<li>Click Submit</li> | ||
<li>Click Reset</li> | ||
</TestCase.Steps> | ||
|
||
<TestCase.ExpectedResult> | ||
The event count should increase by one for every click. | ||
</TestCase.ExpectedResult> | ||
|
||
<form style={formStyle} onSubmit={this.handleSubmit}> | ||
<p>onSubmit calls: {submits}</p> | ||
<input type="submit" /> | ||
</form> | ||
|
||
<form style={formStyle} onReset={this.handleReset}> | ||
<p>onReset calls: {resets}</p> | ||
<input type="reset" /> | ||
</form> | ||
</TestCase> | ||
); | ||
} | ||
} | ||
|
||
export default Form; |
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