Setting a defaultValue for TimePicker using redux-form and materialUI? - reactjs

I can't make any version of setting a defaultValue (or defaultTime or even just value) work for initializing a TimePicker in redux-form from state. All other fields populate correctly, but date/time pickers don't respond to anything. Help is muuuuch appreciated!
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import moment from 'moment';
import { Field, reduxForm, FieldArray, formValueSelector } from 'redux-form';
import MenuItem from 'material-ui/MenuItem';
import {
SelectField,
TextField,
DatePicker,
TimePicker
} from 'redux-form-material-ui';
const selector = formValueSelector('myPantry');
let ServiceGroup = ({ service, index, fields, isAppointment, serviceDate }) =>
<div className="service-type-group" key={index}>
<h4>Service</h4>
<button
type="button"
className="remove-button"
onClick={() => fields.remove(index)}>Remove
</button>
<div className="field-group third">
<Field
name={`${service}.day`}
component={SelectField}
floatingLabelText="Day of week"
className="textfield">
<MenuItem value={1} primaryText="Monday" />
<MenuItem value={2} primaryText="Tuesday" />
</Field>
<Field
name={`${service}.from_time`}
component={TimePicker}
value={null}
floatingLabelText="From"
className="textfield"
/>
<Field
name={`${service}.until_time`}
component={TimePicker}
value={null}
floatingLabelText="To"
className="textfield"
/>
</div>
<div className="field-group half">
<Field
name={`${service}.service_type`}
component={SelectField}
floatingLabelText="Service type"
className="textfield">
<MenuItem value={1} primaryText="First-come first-served" />
<MenuItem value={2} primaryText="Appointment" />
</Field>
</div>
{isAppointment &&
<div className="field-group sentence-inline">
<Field
name={`${service}.max_people`}
type="number"
component={TextField}
label="Number of people per timeslot"
className="textfield"
/>
</div>
}
</div>;
ServiceGroup = connect(
(state, props) => ({
isAppointment: selector(state, `${props.service}.service_type`) == 2,
serviceDate: selector(state, `${props.service}.from_time`)
})
)(ServiceGroup);
class MyPantry extends Component {
static propTypes = {
onSubmit: PropTypes.func.isRequired
}
constructor(props, context) {
super(props, context);
}
renderGroups = ({ fields, meta: { touched, error } }) => {
return (
<div>
{fields.map((service, index) =>
<ServiceGroup service={service} fields={fields} index={index} key={index} />
)}
<button
type="button"
className="action-button"
onClick={() => fields.push({})}>Add Service
</button>
{touched && error && <span>{error}</span>}
</div>
);
}
render() {
const { handleSubmit } = this.props;
return (
<form onSubmit={handleSubmit}>
<div className="section general">
<Field
name="name"
type="text"
component={TextField}
label="Pantry name"
floatingLabelText="Pantry name"
className="textfield full"
/>
<div className="field-group half">
<Field
name="address_street_1"
type="text"
component={TextField}
label="Address"
floatingLabelText="Address"
className="textfield"
/>
<Field
name="address_street_2"
type="text"
component={TextField}
label="Apartment, suite, etc."
floatingLabelText="Apartment, suite, etc."
className="textfield"
/>
</div>
</div>
<h3 className="section-title">Service Setup</h3>
<div className="section service">
<FieldArray name="service_options" component={this.renderGroups} />
</div>
<div>
<button type="submit" className="action-button">Save Pantry Details</button>
</div>
</form>
);
}
}
MyPantry = reduxForm({
form: 'myPantry'
})(MyPantry);
MyPantry = connect(
state => ({
initialValues: state.pantry.data
})
)(MyPantry);
export default MyPantry;

To set default time of TimePicker:
<TimePicker hintText="Pick your time" defaultTime={new Date(2007, 11, 5, 8, 23, 17)} />
here is a working JSFiddle: https://jsfiddle.net/mu5r94m6/2/

You're using this.props.pantry... inside your renderGroups().
You need to bind that function to be able to use this
add a constructor to the class and use bind on that function
constructor(props) {
super(props);
this.renderGroups = this.renderGroups.bind(this);
}

Can now pass format={null} to Time and Date pickers for this. See thread/closed issue here: https://github.com/erikras/redux-form-material-ui/issues/37
and can view tweets that start here: https://twitter.com/megkadams/status/804363887428665345 and continue here: https://twitter.com/megkadams/status/804369699693793280
<Field
name={`${service}.from_time`}
component={TimePicker}
format={(value, name) => {
if (fromTime) {
return value === '' ? null : new Date(fromTime)
} else {
return null;
}
}}
defaultValue={null}
pedantic
floatingLabelText="From"
className="textfield"
/>

Related

React-Redux How can I display the checkbox values?

I am trying to display the checkbox values but it is not showing anything on screen. Whatever values are selected from the checkbox are returning true in the console. How can I display the values that are selected. I am using redux forms. Even I want the values to be displayed in a comma seperated way. How can I achieve this? Thanks in advance.
Here's the code :
AddUser.js
import React, { Component } from 'react'
import { Field, reduxForm } from 'redux-form'
import { connect } from 'react-redux'
import { addUser } from '../../actions'
import './AddUser.css'
class AddUser extends Component {
renderInput(formProps) {
return (
<div>
<label>{formProps.label}</label>
<input {...formProps.input} type={formProps.type} max={formProps.max} autoComplete='off'
label={formProps.label} id={formProps.id}/>
{formProps.meta.touched &&
(formProps.meta.error && <span>{formProps.meta.error}</span>) }
</div>
)
}
onSubmit = (formValues) => {
console.log('formValues', formValues)
this.props.addUser(formValues)
}
render() {
const { handleSubmit } = this.props
const current = new Date().toISOString().split("T")[0]
return (
<div className='container wrapper'>
<form onSubmit={handleSubmit(this.onSubmit)}
className='form'>
<div>
<label>FullName</label>
<Field name='fullname' component={this.renderInput}
type='text' />
</div>
<div>
<label>Address</label>
<Field name='address' component={this.renderInput}
type='text' />
</div>
<div>
<label>BirthDate</label>
<Field name='birthdate' component={this.renderInput}
type='date'
max={current} />
</div>
<div>
<label>Select Your Gender</label>
<Field name='gender' component={this.renderInput} type='radio' value='male'
label='Male' />{' '}
<Field name='gender' component={this.renderInput} type='radio' value='female'
label='Female'/>{' '}
<Field name='gender' component={this.renderInput} type='radio' value='other'
label='Other' />{' '}
</div>
<div>
<label >Select Your Hobbies</label>
<Field name='travelling' component={this.renderInput} type='checkbox' value='travelling'
label='Travelling' />
<Field name='reading' component={this.renderInput} type='checkbox' value='reading'
label='Reading' />
<Field name='gaming' component={this.renderInput} type='checkbox' value='gaming'
label='Gaming' />
<Field name='doodling' component={this.renderInput} type='checkbox' value='doodling'
label='Doodling' />
</div>
<button type='submit'>Submit</button>
</form>
</div>
)
}
}
const validate = (formValues) => {
const errors = {}
if (!formValues.fullname) {
errors.fullname = 'You must enter a fullname'
}
if (!formValues.address) {
errors.address = 'You must enter the address'
}
if(!formValues.birthdate){
errors.birthdate='Please select your date of birth'
}
if(!formValues.gender){
errors.gender='Please select your gender'
}
return errors
}
export default connect(null, {
addUser: addUser
})(reduxForm({
form: 'adduser',
validate: validate
})(AddUser))
UsersList.js
import React, { Component } from 'react'
import {connect} from 'react-redux'
import {listAllUsers} from '../../actions'
class ListUsers extends Component {
componentDidMount(){
this.props.listAllUsers()
}
usersList(){
return this.props.users.map((user)=>{
return (
<div key={user.id}>
<div>{user.fullname}</div>
<div>{user.address}</div>
<div>{user.birthdate}</div>
<div>{user.gender}</div>
<div>{user.hobbies}</div>
<div>
<button>Edit</button>
</div>
<div>
<button>Delete</button>
</div>
</div>
)
})
}
render() {
return (
<div>
<h1>Users List</h1>
{this.usersList()}
</div>
)
}
}
const mapStateToProps=(state)=>{
console.log(state)
return {users:state.users}
}
export default connect(mapStateToProps,{listAllUsers:listAllUsers})(ListUsers)
I'll show you an example for showing checkbox value in 1 line, you should be able do it on your own case.
function App() {
const [selectedInput, setSelectedInput] = React.useState([]);
const renderSelected = (e) => {
const targtValue = e.currentTarget.value;
setSelectedInput((prev)=>
prev.some(data => data === targtValue ) ?
prev.filter(data => data !== targtValue ) :
[...prev, targtValue]
)
}
return (
<div>
<label >Select Your Hobbies:</label><br/>
<p>{selectedInput.map(data=>data+",")}</p>
<label>Travelling
<input name='travelling' onChange={renderSelected} type='checkbox' value='travelling'/></label>
<label>Reading
<input name='reading' onChange={renderSelected} type='checkbox' value='reading'/></label>
<label>Gaming
<input name='gaming' onChange={renderSelected} type='checkbox' value='gaming' /></label>
<label>Doodling
<input name='doodling' onChange={renderSelected} type='checkbox' value='doodling'/></label>
</div>
);
}
ReactDOM.render(
<App/>,
document.getElementById("react")
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.8.4/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.4/umd/react-dom.production.min.js"></script>
<div id="react"></div>

How to change a field in a redux-form?

In my react component I am trying to set a field called 'total'. I have imported the change action as a prop into my component:
import React, { Component, Fragment } from 'react'
import { Field, FieldArray, reduxForm, getFormValues, change } from 'redux-form'
import { connect } from 'react-redux'
import { CalcTotal } from './calculationHelper';
const renderField = ({ input, label, type, meta: { touched, error } }) => (
<div>
<label>{label}</label>
<div>
<input {...input} type={type} placeholder={label} />
{touched && error && <span>{error}</span>}
</div>
</div>
)
const renderMods = ({ fields, meta: { error, submitFailed } }) => (
<Fragment>
<ul>
<li>
<button type="button" onClick={() => fields.push({})}>
Add Modification
</button>
{submitFailed && error && <span>{error}</span>}
</li>
{fields.map((mod, index) => (
<li key={index}>
<button
type="button"
title="Remove Mod"
onClick={() => fields.remove(index)}
/>
<h4>Mod #{index + 1}</h4>
<Field
name={`${mod}.lastYear`}
type="number"
component={renderField}
label="Last Year"
/>
<Field
name={`${mod}.currentYear`}
type="number"
component={renderField}
label="Current Year"
/>
<Field name={`${mod}.type`} component="select" label="Type">
<option />
<option value="-">Expense</option>
<option value="+">Income</option>
<option value="-">Tax</option>
</Field>
</li>
))}
</ul>
<Field
name="total"
type="number"
component="input"
label="Total modifications"
text="0"
/>
</Fragment>
)
class FieldArraysForm extends Component {
render() {
const { handleSubmit, formValues, change } = this.props
if (formValues) {
console.log('formvalues', formValues);
const test = CalcTotal(2000);
console.log('calc=', test);
debugger
this.props.change('fieldArraysForm', 'total', 5000)
}
return (
<form onSubmit={handleSubmit}>
{/* <button onClick={this.changeStuff}>set total</button> */}
<FieldArray name="mods" component={renderMods} />
<div>
<button type="submit" >
Submit
</button>
</div>
</form>
)
}
}
const mapStateToProps = (state) => ({
formValues: getFormValues('fieldArraysForm')(state),
});
const mapDispatchToProps = {
change
};
// const Example = reduxForm({
// form: 'fieldArraysForm', // a unique identifier for this form
// })(FieldArraysForm)
// const ConnectedForm = connect(
// mapStateToProps,
// mapDispatchToProps,
// )(Example);
// export default ConnectedForm
export default reduxForm({
form: "fieldArraysForm"
})(
connect(
mapStateToProps,
mapDispatchToProps
)(FieldArraysForm)
);
The line where the code fall into an infinite loop:
this.props.change('fieldArraysForm', 'total', 5000)
How /where do I put this statement to make sure the 'total' field is changed and not get into a loop?Which React lifecycle event would suit? I want to fire this whenever there is a form change on any field.
You'll need to move your statement out of the render method and into the componentDidUpdate lifecycle method (you also need an if statement to prevent an infinite loop):
componentDidUpdate(prevProps) {
if (this.props.someValue !== prevProps.someValue) {
this.props.change("formName", "formField", "newFormValue");
}
}
Working example: https://codesandbox.io/s/r5zz36lqnn (selecting the Has Email? radio button populates the email field with test#example.com, unselecting the radio button resets the email field to "")

Cant access shallow rendered component when testing - 0 nodes found

I am trying to unit-test my React components using JEST and enzyme.
In this case I wanna test a redux-form component, so I tried following this guide:
https://github.com/tylercollier/redux-form-test/blob/master/tests/unit/index.js#L10
But I always get the error: Method “simulate” is only meant to be run on a single node. 0 found instead.
I realize that this is because it cant find the element that I am locating in .find('someElement'), but I cant figure out how to access it correctly. I have tried changing form in subject.find('form') to MenuInputFields and inputItemList, but the result is the same.
EDIT
I found that the error is present because the component is wrapped in a redux-form with:
MenuInputFields = reduxForm({
form: 'inputItemList',
validate
})(MenuInputFields)
Removing this makes it possible to somewhat test the component, however this is (of course) not optimal. When removing the connection with redux-forms I am able to access the form, but not any of the elements within it, accessing anything else than forms always yields the same error as I got before (shown further up).
I have changed the output of subject.debug() to the result after i removed the redux-form-wrapping, and now you can see that my fields are actually in the form, I just cant access them. I also update the testcases to show what works and what doesnt.
My Test:
import React from 'react'
import configureStore from 'redux-mock-store'
import Adapter from 'enzyme-adapter-react-15'
import * as sinon from 'sinon'
import * as Enzyme from 'enzyme'
import { Provider } from 'react-redux'
import { mount, shallow, render } from 'enzyme'
import { menuList } from '../../stubs/menuList'
import { MenuInputFields } from '../../components/adminMenuInputFields'
Enzyme.configure({ adapter: new Adapter() })
describe('<MenuInputFields />', () => {
let subject
let handleSubmit, pristine, reset, submitting, submitForm, touched, error
beforeEach(() => {
submitting = false
pristine = true
error = null
reset = sinon.spy()
handleSubmit = fn => fn
})
const buildSubject = () => {
submitForm = sinon.stub()
const props = {
submitForm,
initialValues: {
ClosingTime: '14:00',
MenuItems: {
FoodItem: 'test',
Description: 'test',
Price: '66'
}
},
handleSubmit,
reset
}
return shallow(<MenuInputFields {...props}/>)
}
//This works
it('it calls submitForm once when submitting', () => {
subject = buildSubject()
subject.find('form').simulate('submit')
expect(submitForm.calledOnce).toBeTruthy()
})
//This doesnt work
it('loads initial value of ClosingTime into input-box ', () => {
subject = buildSubject()
let closingTime = subject.find('form')
expect(closingTime).toEqual('14:00')
})
//This doesnt work
it('Renders the "tilføj" button', () => {
subject = buildSubject()
let button = subject.find('.addItemRow')
expect(button.text()).toEqual('Tilføj')
})
})
My component
class MenuInputFields extends React.Component {
constructor(props){
super(props)
}
render() {
let currentDate = new Date()
let formattedDate = currentDate.toLocaleDateString('en-GB')
const renderField = ({ input, label, type, className, meta: { touched, error } }) => (
<div>
<input {...input} type={type} placeholder={label} className={className} />
{touched && error && <span>{error}</span>}
</div>
);
const renderMenuItem = ({fields, meta: {touched, error, submitFailed }}) => (
<ul className='adminInputFoodItem'>
{fields.map((MenuItem, index) => (
<li key={index}>
<p className='col-md-1'> {index+1} - </p>
<Field
name={`${MenuItem}.FoodItem`}
type='text'
component={renderField}
label='Titel'
className='col-md-2'
/>
<Field
name={`${MenuItem}.Description`}
type='text'
component={renderField}
label='Beskrivelse'
className='col-md-6'
/>
<Field
name={`${MenuItem}.Price`}
type='number'
component={renderField}
label='Pris'
className='col-md-1'
/>
<button
type='button'
title='Fjern'
onClick={() => fields.remove(index)}
className='btn btn-default btn-xs remItemRow'
>Fjern
</button>
</li>
))}
<li>
</li>
<li>
<button
type='button'
onClick={() => fields.push({})}
className='btn btn-default btn-sm addItemRow'
>Tilføj
</button>
{submitFailed && error && <span>{error}</span>}
</li>
</ul>
);
const { handleSubmit, pristine, reset, submitting, submitForm } = this.props
return (
<form className='adminInputForm' onSubmit={handleSubmit(submitForm)}>
<label className='col-md-2' >Dato: {formattedDate}</label>
<br />
<br />
<ul className='adminInputFoodItem'>
<li>
<label className='col-md-1'> Lukketid: </label>
<Field
name='ClosingTime'
type='text'
component={renderField}
label='TT:mm'
className='col-md-1'
/>
</li>
</ul>
<hr />
<div>
<label className='col-md-1'> # </label>
<label className='col-md-2'> Titel </label>
<label className='col-md-3'> Beskrivelse </label>
<label className='col-md-1'> Pris </label>
</div>
<br />
<br />
<FieldArray name='MenuItems' component={renderMenuItem} />
<br />
<div className=''>
<button
className='btn btn-default'
type='submit'
disabled={pristine || submitting}
>Gem Menu
</button>
<label>Submit besked her</label>
</div>
</form>
)
}
}
MenuInputFields = reduxForm({
form: 'inputItemList',
validate
})(MenuInputFields)
export default MenuInputFields
The container which renders the component:
const mapDispatchToProps = (dispatch) => {
return {
setMenu: (menu) => dispatch(setMenu(menu)),
submitForm: (newMenu) => dispatch(postMenuRequest(newMenu))
}
}
class AdminSetMenuView extends React.Component {
constructor(props){
super(props)
}
componentWillMount(){
this.props.setMenu(this.props.data)
}
render(){
return(
<div>
<AdminRoutes />
<br />
<br />
<div>
<MenuInputFields
initialValues={this.props.initialValues}
submitForm={this.props.submitForm} />
</div>
</div>
)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(AdminSetMenuView)
output from console.log(subject.debug()):
<form className="adminInputForm" onSubmit={[Function: proxy]}>
<label className="col-md-2">
Dato:
3/8/2018
</label>
<br />
<br />
<ul className="adminInputFoodItem">
<li>
<label className="col-md-1">
Lukketid:
</label>
<Field name="ClosingTime" type="text" component={[Function: renderField]} label="TT:mm" className="col-md-1" />
</li>
</ul>
<hr />
<div>
<label className="col-md-1">
#
</label>
<label className="col-md-2">
Titel
</label>
<label className="col-md-3">
Beskrivelse
</label>
<label className="col-md-1">
Pris
</label>
</div>
<br />
<br />
<FieldArray name="MenuItems" component={[Function: renderMenuItem]} />
<br />
<div className="">
<button className="btn btn-default" type="submit" disabled={[undefined]}>
Gem Menu
</button>
<label>
Submit besked her
</label>
</div>

How get values from a select/option field in redux-form?

I am trying to get the values from my second form. It renders some select options and when I hit the delete button it just returns an empty object. How do I get the value from the options. With the normal input fields it would pass values with the name.
For example if I had an input type="text" name="email", when I would submit this it would give my an object like:
{email: "some string"}
Here is the code:
import React , { Component } from 'react';
// import * as actions from '../actions';
import { reduxForm, Field } from 'redux-form';
import {connect} from 'react-redux';
import {postBooks, deleteBook} from '../../actions/booksActions';
class BooksForm extends Component {
renderField(field) {
const { meta: {touched, error} } = field;
const className = `form-group ${touched && error ? 'has-danger' : ''}`;
return (
<div className={className}>
<label className="control-label"><strong>{field.label}:</strong></label>
<input
className="form-control"
type={field.type}
{...field.input}
/>
<div className="text-help">
{ touched ? error : ''}
</div>
</div>
);
}
renderSelectField(field) {
const bookList = _.map(field.options, (book) => {
return (
<option key={book._id}>{book.title}</option>
)
});
return(
<div className="form-group">
<label htmlFor="sel1" className="control-label">{field.label}</label>
<select className="form-control" id="sel1">
{bookList}
</select>
</div>
);
}
onSubmit(values) {
this.props.postBooks(values);
}
onDelete(values) {
console.log(values);
}
render() {
const {handleSubmit} = this.props;
return (
<div>
<div className="well">
<form className="panel" onSubmit={handleSubmit(this.onSubmit.bind(this))}>
<div className="panel-body">
<Field
label="Title"
name="title"
type="text"
component={this.renderField}
/>
<Field
label="Description"
name="description"
type="text"
component={this.renderField}
/>
<Field
label="Price"
name="price"
type="text"
component={this.renderField}
/>
<button className="btn btn-primary">Save Book</button>
</div>
</form>
</div>
<form className="Panel" onSubmit={handleSubmit(this.onDelete.bind(this))}>
<div className="panel-body">
<Field
label="Select Book"
name="selectedBook"
options={this.props.books}
component={this.renderSelectField}
/>
<button className="btn btn-danger">Delete</button>
</div>
</form>
</div>
);
}
}
function validate(values) {
const errors = {};
return errors;
}
function mapStateToProps(state) {
return {
books: state.books
}
}
export default reduxForm({
validate,
form: 'bookForm'
})(connect(mapStateToProps, {postBooks, deleteBook})(BooksForm));
In renderSelectField I needed to add {...field.input} into the select to allow redux-form to monitor it.
<select className="form-control" id="sel1" {...field.input}>

ReduxForm: using formValueSelector within a FieldArray for conditional fields doesn't render immediately

This sort of works, except additional block doesn't show up when I make a service_type radio selection, it only pops up/re-renders if I complete an additional action, like adding or removing a service block or changing another field.
import './Register.scss';
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { Field, reduxForm, FieldArray, formValueSelector } from 'redux-form';
import MenuItem from 'material-ui/MenuItem';
import { RadioButton } from 'material-ui/RadioButton'
import {
TextField,
SelectField,
TimePicker,
RadioButtonGroup
} from 'redux-form-material-ui';
import validate from './validate';
class OnboardPageThree extends Component {
static propTypes = {
handleSubmit: PropTypes.func.isRequired,
previousPage: PropTypes.func.isRequired
}
constructor(props, context) {
super(props, context);
}
renderGroups = ({ fields, meta: { touched, error } }) => {
return (
<div>
{fields.map((service, index) =>
<div className="service-type-group" key={index}>
<h4>{index} Service</h4>
<button
type="button"
className="remove-button"
onClick={() => fields.remove(index)}>Remove
</button>
<div className="field-group half">
<Field
name={`${service}.service_type`}
component={RadioButtonGroup}
floatingLabelText="Service type"
className="textfield">
<RadioButton value="first_come_first_serve" label="First-come first-served"/>
<RadioButton value="appointments" label="Appointment"/>
</Field>
</div>
{/* Sort of works except doesn't populate until forced re-render by adding another to array or updating a previous field */}
{typeof this.props.services[index].service_type != undefined && this.props.services[index].service_type == "first_come_first_serve" ? <div className="fieldset">
<p className="label">Timeslot capacity and length when creating a first-come-first-served (line-based) service blocks</p>
<div className="field-group sentence-inline">
<Field
name={`${service}.max_people`}
type="number"
component={TextField}
label="Number of people per timeslot"
className="textfield"
/>
<p>people are allowed every</p>
<Field
name={`${service}.time_interval`}
component={SelectField}
className="textfield">
<MenuItem value="5" primaryText="5 minutes" />
<MenuItem value="10" primaryText="10 minutes" />
<MenuItem value="15" primaryText="15 minutes" />
<MenuItem value="30" primaryText="30 minutes" />
<MenuItem value="60" primaryText="60 minutes" />
<MenuItem value="all_day" primaryText="All day" />
</Field>
<p>.</p>
</div>
</div> : null}
</div>
)}
<button
type="button"
className="action-button"
onClick={() => fields.push({})}>Add Service
</button>
{touched && error && <span className="error-message">{error}</span>}
</div>
);
}
render() {
const { handleSubmit, previousPage } = this.props;
return (
<form onSubmit={handleSubmit}>
<h2>When do you provide service?</h2>
<FieldArray name="service_options" component={this.renderGroups} />
<div className="justify-flex-wrapper service-actions">
<button type="button" className="back-button" onClick={previousPage}>Back</button>
<button type="submit" className="action-button">Next</button>
</div>
</form>
);
}
}
OnboardPageThree = reduxForm({
form: 'onboarding',
destroyOnUnmount: false,
validate
})(OnboardPageThree)
const selector = formValueSelector('onboarding');
OnboardPageThree = connect(
(state) => {
const services = selector(state, 'service_options');
return {
services
};
}
)(OnboardPageThree);
export default OnboardPageThree;
Yes, that is true. The FieldArray does not re-render on the change of any of its items (that would be really bad for large arrays), only on size changes.
You will have to create a separate connected component for your array items. I have worked up a working demo here.

Resources