File tree 7 files changed +75
-5
lines changed 7 files changed +75
-5
lines changed Original file line number Diff line number Diff line change 1
1
{
2
- "presets" : [" es2015" , " react" ]
2
+ "presets" : [" es2015" , " react" ],
3
+ "plugins" : [" react-hot-loader/babel" ]
3
4
}
Original file line number Diff line number Diff line change @@ -14,9 +14,13 @@ class ContactForm extends Component {
14
14
15
15
return (
16
16
< form onSubmit = { this . props . handleSubmit ( this . mySubmit . bind ( this ) ) } >
17
+ < h1 > Contact Form</ h1 >
17
18
< label > First name</ label >
19
+ { ' ' }
18
20
< input { ...firstName } />
19
- { firstName . touched && firstName . error && < div className = 'help-block' > { firstName . error } </ div > }
21
+ { ' ' }
22
+ { firstName . touched && firstName . error && < span className = 'help-block' > { firstName . error } </ span > }
23
+ < p > </ p >
20
24
< button type = "submit" >
21
25
< i className = { submitClassName } /> Submit
22
26
</ button >
Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
+ import { connect } from 'react-redux'
2
3
import ContactFormComponent from './ContactFormComponent'
3
4
import { reduxForm } from 'redux-form'
4
5
import * as formValidations from './formValidations'
5
6
6
- const ContactFormContainer = reduxForm ( {
7
+ let ContactFormContainer = reduxForm ( {
7
8
form : 'contact' ,
8
9
fields : [ 'firstName' ] ,
9
10
validate : formValidations . createValidator ( {
10
11
firstName : formValidations . required
11
12
} )
12
13
} ) ( ContactFormComponent )
13
14
15
+ const mapStateToProps = null
16
+ const mapDispatchToProps = {
17
+ // Note: we aren't actually doing anything with this. The ContactForm component has a propType, so I'm showing where it might come from.
18
+ onSave : contactFormValues => { return { type : 'FORM_SUBMIT' , payload : contactFormValues } }
19
+ }
20
+
21
+ ContactFormContainer = connect ( mapStateToProps , mapDispatchToProps ) ( ContactFormContainer )
22
+
14
23
export default ContactFormContainer
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { render } from 'react-dom'
3
+ import { createStore , combineReducers } from 'redux'
4
+ import { Provider } from 'react-redux'
5
+ import { reducer as reduxFormReducer } from 'redux-form'
6
+ import ContactFormContainer from './ContactFormContainer'
7
+
8
+ const rootReducer = combineReducers ( {
9
+ form : reduxFormReducer
10
+ } )
11
+ const store = createStore ( rootReducer , window . devToolsExtension && window . devToolsExtension ( ) )
12
+
13
+ render (
14
+ < Provider store = { store } >
15
+ < ContactFormContainer />
16
+ </ Provider > ,
17
+ document . getElementById ( 'root' )
18
+ )
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < title > redux-form-test</ title >
5
+ < style >
6
+ .help-block {
7
+ color : red;
8
+ }
9
+ </ style >
10
+ </ head >
11
+ < body >
12
+ < div id ="root "> </ div >
13
+ < script src ="bundle.js "> </ script >
14
+ </ body >
15
+ </ html >
Original file line number Diff line number Diff line change 4
4
"description" : " Showing some unit and integration tests for redux-form" ,
5
5
"keywords" : [],
6
6
"scripts" : {
7
- "webpack " : " node_modules/.bin/webpack" ,
7
+ "dev " : " node_modules/.bin/webpack-dev-server " ,
8
8
"test" : " node_modules/.bin/mocha -w --compilers js:babel-core/register tests/*"
9
9
},
10
10
"devDependencies" : {
19
19
"mocha" : " ^2.4.5" ,
20
20
"react-addons-test-utils" : " ^15.0.2" ,
21
21
"sinon" : " ^1.17.4" ,
22
- "webpack" : " ^1.13.0"
22
+ "webpack" : " ^1.13.0" ,
23
+ "webpack-dev-server" : " ^1.15.1"
23
24
},
24
25
"dependencies" : {
25
26
"react" : " ^15.0.2" ,
26
27
"react-dom" : " ^15.0.2" ,
28
+ "react-hot-loader" : " ^3.0.0-beta.3" ,
27
29
"react-redux" : " ^4.4.5" ,
28
30
"redux" : " ^3.5.2" ,
29
31
"redux-form" : " ^5.2.3"
Original file line number Diff line number Diff line change
1
+ const webpack = require ( 'webpack' )
2
+
3
+ module . exports = {
4
+ entry : {
5
+ app : './app/index.js'
6
+ } ,
7
+ module : {
8
+ loaders : [
9
+ { pattern : / \. j s x ? / , loader : 'babel' , exclude : / n o d e _ m o d u l e s / }
10
+ ]
11
+ } ,
12
+ plugins : [ new webpack . HotModuleReplacementPlugin ( { } ) ] ,
13
+ devServer : {
14
+ historyApiFallback : true ,
15
+ hot : true ,
16
+ stats : {
17
+ colors : true ,
18
+ chunks : false
19
+ }
20
+ } ,
21
+ }
You can’t perform that action at this time.
0 commit comments