enter image description here enter image description here
COMPONENT.JS
array = [{name: 'name1', id: 1},{name: 'name2', id: 2}]
<div *ngFor="let name of array">
<p>Name: {{name.name}}</p> // Hard coded here (Name:)
</div>
ACTIONS.JS
class CreatGroup extends React.Component{
// function to post
handleFormSubmit = (dataForm) => {
console.log(dataForm, ' DATA FORM')
this.props.dispatch(createPostGroup(dataForm))
}
render() {
// my form
const { handleSubmit, submitting } = this.props
return(
<div>
<form onSubmit={handleSubmit(this.handleFormSubmit)}>
<div>
<Field name="amount" component={renderField} type="number" label="amount" />
</div>
<div>
<Field name="duration" component={renderField} type="number" label="duration" />
</div>
<div>
<Field name="limit_members" component={renderField} type="number" label="max members" />
</div>
<div>
<button type="submit" disabled={submitting}>Submit</button>
</div>
</form>
</div>
)
}
}
CreatGroup = reduxForm({
form:'creat-group'
})(CreatGroup)
REDUCER.JS
// CONST ACTIONS
const CREATE_GROUP = 'CREATE_GROUP'
//ACTIONS
export function createPostGroup(data){ return { type: CREATE_GROUP, data}};
COMBINE REDUCER.JS
// REDUCER
export default function groupReducer( state= {}, action){
switch (action.type){
case CREATE_GROUP:
return action.data
case CREATE_GROUP_FAIL:
return {
...state
}
default:
return state
}
}
SAGAS.JS
也许问题来自那里?
// COMBINE REDUCER
const reducer = combineReducers({
groupReducer,
form: formReducer
});