Skip to content

Re-order examples and add handleClick #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Empty file.
26 changes: 26 additions & 0 deletions 13-form-validation/a-validation/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React, { Component } from 'react';
import Field from './Field';

class App extends Component {
render() {
return (
<div>
<Field
required
name="test"
label="required text field "
onChange={(e) => console.log('change', e)}
/><br/>
<Field
type="number"
max={20}
name="test"
label="number field (20 max) "
onChange={(e) => console.log('change', e)}
/>
</div>
)
}
}

export default App;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// App.css
input:invalid + .pure-form-message-inline {
color: #c61c06;
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import './App.css';
import '../node_modules/purecss/build/base.css';
import '../node_modules/purecss/build/forms.css';
import './Field.css';

class Field extends Component {
static defaultProps = {
Expand All @@ -12,6 +12,7 @@ class Field extends Component {
invalidmsg: null,
value: this.props.value
}

render () {
const {
name,
Expand All @@ -38,6 +39,7 @@ class Field extends Component {
</div>
);
}

handleChange (e, onChange) {
this.setState({
value: e.target.value
Expand All @@ -61,27 +63,5 @@ class Field extends Component {
this.setState({ invalidmsg });
}
}

class App extends Component {
render() {
return (
<div>
<Field
required
name="test"
label="required text field "
onChange={(e) => console.log('change', e)}
/><br/>
<Field
type="number"
max={20}
name="test"
label="number field (20 max) "
onChange={(e) => console.log('change', e)}
/>
</div>
)
}
}

export default App;
export default Field;
File renamed without changes.
Loading