Skip to content

Conversation

@NasgulNexus
Copy link
Contributor

  1. In the controller, instead of the initial value, there will be a value.
  2. From the final form we pull out the initial value and value.

@NasgulNexus NasgulNexus requested a review from bocembocem as a code owner May 11, 2023 10:17
@gravity-ui-bot
Copy link
Contributor

Preview is ready.

parentOnChange={null}
parentOnUnmount={null}
initialValue={_.get(tools.initialValue, name)}
value={_.get(tools.values, name)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

U need to take values from store, not from tools

}

const error = validate?.(value);
const isDiffentValues = !_.isEqual(value, initialValue);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*diffeREnt
Prefix is better to use for functions
You're checking dirty here, let's give a name for variable dirty too

pristine: false,
touched: false,
modified: isDiffentValues,
pristine: isDiffentValues,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

U can't use isEqual to check for pristine, only ===

const tools = React.useMemo(
() => ({
initialValue: store.initialValue,
values: store.values,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to include values in tools

errors: errors || {},
})),
onUnmount: (name: string) =>
onUnmount: (name: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointless changes, let's remove back

tools: {
initialValue: FieldObjectValue;
initialValue: FieldValue;
values: FieldValue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also remove values

@NasgulNexus NasgulNexus merged commit ce52d65 into main May 17, 2023
@NasgulNexus NasgulNexus deleted the fix-initial-value branch May 17, 2023 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants