Skip to content

Commit

Permalink
Change final form props spreading
Browse files Browse the repository at this point in the history
Change props spreading so that the whole props object is available to
the form and required props can be destructured from that.
  • Loading branch information
lyyder committed Jun 1, 2018
1 parent 3a7dc5a commit cdfd6e0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/forms/EmailVerificationForm/EmailVerificationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import css from './EmailVerificationForm.css';
const EmailVerificationFormComponent = props => (
<FinalForm
{...props}
render={fieldRenderProps => {
const { currentUser, inProgress, handleSubmit, verificationError } = fieldRenderProps;
render={formRenderProps => {
const { currentUser, inProgress, handleSubmit, verificationError } = formRenderProps;

const { email, emailVerified, pendingEmail, profile } = currentUser.attributes;
const emailToVerify = <strong>{pendingEmail || email}</strong>;
Expand Down
3 changes: 2 additions & 1 deletion src/forms/LocationSearchForm/LocationSearchForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const LocationSearchFormComponent = props => {
return (
<FinalForm
{...props}
render={({ rootClassName, className, intl, handleSubmit }) => {
render={formRenderProps => {
const { rootClassName, className, intl } = formRenderProps;
const classes = classNames(rootClassName || css.root, className);

// Allow form submit only when the place has changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const SelectMultipleFilterFormComponent = props => {
<FinalForm
{...props}
mutators={{ ...arrayMutators }}
render={formProps => {
render={formRenderProps => {
const {
form,
handleSubmit,
Expand All @@ -25,7 +25,7 @@ const SelectMultipleFilterFormComponent = props => {
contentRef,
style,
intl,
} = formProps;
} = formRenderProps;
const classes = classNames(css.root, { [css.isOpen]: isOpen });

const handleCancel = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ const SelectMultipleFilterPlainForm = props => {
{...rest}
onSubmit={() => null}
mutators={{ ...arrayMutators }}
render={({ className, name, options, twoColumns, onChange }) => (
<Form className={className}>
<FormSpy onChange={handleChange} subscription={{ values: true, dirty: true }} />
<FieldCheckboxGroup name={name} id={name} options={options} twoColumns={twoColumns} />
</Form>
)}
render={formRenderProps => {
const { className, name, options, twoColumns } = formRenderProps;
return (
<Form className={className}>
<FormSpy onChange={handleChange} subscription={{ values: true, dirty: true }} />
<FieldCheckboxGroup name={name} id={name} options={options} twoColumns={twoColumns} />
</Form>
);
}}
/>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/forms/SendMessageForm/SendMessageForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SendMessageFormComponent extends Component {
return (
<FinalForm
{...this.props}
render={fieldRenderProps => {
render={formRenderProps => {
const {
rootClassName,
className,
Expand All @@ -66,7 +66,7 @@ class SendMessageFormComponent extends Component {
sendMessageError,
invalid,
form,
} = fieldRenderProps;
} = formRenderProps;

const classes = classNames(rootClassName || css.root, className);
const submitInProgress = inProgress;
Expand Down
4 changes: 3 additions & 1 deletion src/forms/TopbarSearchForm/TopbarSearchForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class TopbarSearchFormComponent extends Component {
return (
<FinalForm
{...this.props}
render={({ rootClassName, className, desktopInputRoot, intl, isMobile }) => {
render={formRenderProps => {
const { rootClassName, className, desktopInputRoot, intl, isMobile } = formRenderProps;

const classes = classNames(rootClassName, className);
const desktopInputRootClass = desktopInputRoot || css.desktopInputRoot;

Expand Down

0 comments on commit cdfd6e0

Please sign in to comment.