Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form - Migrate setNativeProps to state. #11039

Merged
merged 31 commits into from
Oct 7, 2022
Merged

Form - Migrate setNativeProps to state. #11039

merged 31 commits into from
Oct 7, 2022

Conversation

rushatgabhane
Copy link
Member

@rushatgabhane rushatgabhane commented Sep 16, 2022

Details

setNativeProps will not be supported in the post-Fabric world (docs). Removing it's usage is a prerequisite to enable Fabric in #8503 . I'm creating multiple PRs to migrate it's usage. This is one of many.

Form is made controlled, and Picker's usage of setNativeProps has been removed.

Fixed Issues

$ #11049
$ #11646
$ #11654
$ #10437

Tests

Form component

  1. Run npm run storybook and test Form. Make sure that we can edit the input and all values are updated accordingly.
  2. Verify that form inputs validate on Blur and Submit.
  3. Verify that the correct values are being submitted.

Picker

  1. Run npm run storybook and test picker functionalities. Make sure that we can edit the input and all values are updated accordinly.
  2. Test ALL usages of Picker (any dropdown select input) in the app. Set new value, update value and verify error states
  • Settings > Payments > Add payment method > Add debit card > Select state
  • Workspace > Connect bank account (Additional information) > State
  • Policy room (#announce) > Settings > Notify me about new messages
  • Settings > Preferences > Priority mode
  • Settings > Preferences > Language
  • Settings > Profile > Preferred pronouns
  • Settings > Profile > Timezone
  • Workspace > Connect bank account (Company step) > Address state
  • Workspace > Connect bank account (Company step) > Company type
  • Workspace > Connect bank account (Company step) > Corporation state
  • Workspace > Connect bank account (Personal information) > State
  • Login page > Select locale (below terms and conditions)

Address search

  1. Go to Settings - Payments -> Add payment method -> Add debit card page
  2. Verify that you can search for an address.
  3. Verify that you can select an address.
  4. Verify that Street address, City, State and Zipcode are autofilled after selecting the address.

Pages using Form.js

  1. Add debit card page
    1. Go to Settings - Payments -> Add payment method -> Add debit card page
    2. Verify that you can edit all inputs.
    3. Verify that the input is being validated on blur, and submit.
  2. Request a call page
    1. Go to Concierge -> Click on the call button
    2. Verify that you can edit all inputs.
    3. Verify that the input is being validated on blur, and submit.
  3. Profile page
    1. Go to settings -> Profile
    2. Verify that you can edit all inputs.
    3. Verify that the input is being validated on blur, and submit.

Blueline around the fields

  1. Go to Settings->Workspaсe->General settings
  2. Change the workspace name and then change the currency
  3. Verify that the two fields aren't highlighted at the same time
  • Verify that no errors appear in the JS console

PR Review Checklist

Contributor (PR Author) Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

PR Reviewer Checklist

The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

QA Steps

Form component

  1. Go to storybook and test Form. Make sure that we can edit the input and all values are updated accordingly.
  2. Verify that form inputs validate on Blur and Submit.
  3. Verify that the correct values are being submitted.

Picker

  1. Run npm run storybook and test picker functionalities. Make sure that we can edit the input and all values are updated accordinly.
  2. Test ALL usages of Picker (any dropdown select input) in the app. Set new value, update value and verify error states
  • Settings > Payments > Add payment method > Add debit card > Select state
  • Workspace > Connect bank account (Additional information) > State
  • Policy room (#announce) > Settings > Notify me about new messages
  • Settings > Preferences > Priority mode
  • Settings > Preferences > Language
  • Settings > Profile > Preferred pronouns
  • Settings > Profile > Timezone
  • Workspace > Connect bank account (Company step) > Address state
  • Workspace > Connect bank account (Company step) > Company type
  • Workspace > Connect bank account (Company step) > Corporation state
  • Workspace > Connect bank account (Personal information) > State
  • Login page > Select locale (below terms and conditions)

Address search

  1. Go to Settings - Payments -> Add payment method -> Add debit card page
  2. Verify that you can search for an address.
  3. Verify that you can select an address.
  4. Verify that Street address, City, State and Zipcode are autofilled after selecting the address.

Pages using Form.js

  1. Add debit card page
    1. Go to Settings - Payments -> Add payment method -> Add debit card page
    2. Verify that you can edit all inputs.
    3. Verify that the input is being validated on blur, and submit.
  2. Request a call page
    1. Go to Concierge -> Click on the call button
    2. Verify that you can edit all inputs.
    3. Verify that the input is being validated on blur, and submit.
  3. Profile page
    1. Go to settings -> Profile
    2. Verify that you can edit all inputs.
    3. Verify that the input is being validated on blur, and submit.

Blueline around the fields

  1. Go to Settings->Workspaсe->General settings
  2. Change the workspace name and then change the currency
  3. Verify that the two fields aren't highlighted at the same time
  • Verify that no errors appear in the JS console

Screenshots

Web

Form - Profile Page

Screen.Recording.2022-10-05.at.2.15.17.AM.mov

Form - Debit card page

Screen.Recording.2022-10-05.at.2.18.38.AM.mov

Non Form Picker - Preferences page

Screen.Recording.2022-10-05.at.2.37.04.AM.mov

Mobile Web

Screen.Recording.2022-10-05.at.2.34.09.AM.mov

Desktop

Working of the Address search component

Screen.Recording.2022-10-05.at.2.24.43.AM.mov

iOS

image

Android

WhatsApp Image 2022-10-05 at 03 01 41

screen-20221005-030018.mp4

Storybook

Screen.Recording.2022-10-05.at.3.02.08.AM.mov

@rushatgabhane rushatgabhane requested a review from a team as a code owner September 16, 2022 01:15
@melvin-bot
Copy link

melvin-bot bot commented Sep 16, 2022

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@melvin-bot melvin-bot bot requested review from stitesExpensify and removed request for a team September 16, 2022 01:15
return;
}

this.props.onInputChange(value, index);
Copy link
Member Author

@rushatgabhane rushatgabhane Sep 16, 2022

Choose a reason for hiding this comment

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

Question from @parasharrajat - How is this change related to removing setNativeProps?

Rushat:

Anytime a Form input's value is changed, onInputChange() is called.

If you'll look at Form.js

App/src/components/Form.js

Lines 161 to 166 in 97ebb65

onInputChange: (value, key) => {
const inputKey = key || inputID;
this.setState(prevState => ({
inputValues: {
...prevState.inputValues,
[inputKey]: value,

It keeps track of input values based on the key provided to it.
And this "key" is supposed to be the formID used by the Form input.

So our expected function call looks something like this - onInputChange('Portugal', 'countryPicker')


Prerequisite: Picker is used in a Form.

Now RNPickerSelect comes into picture.

It passes the picker item's index as the second parameter. (source)

So this is what actually gets called - onInputChange('Portugal', 156). (where 156 is the index of Portugal in a list)

Our Form based picker now will try to change the value of an input whose formID is 156.
And bam 💥 our Form based picker doesn't work anymore.

I'm just fixing this by passing the formID as the second param, because we don't care aobut the index lol

This wasn't a problem before because Form previously set the value using ref.setNativeProps.
We're getting rid of that now. So we gotta fix it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

The explanation makes sense, but I'm not sure that this is necessary. From the Form docs, the intent of the second param is to:

Passing an inputID as a second param allows inputA to manipulate the input value of the provided inputID (inputB).

If you look at Form, we have const inputKey = key || inputID; so if key (the 2nd param) is not provided, we will automatically use the inputID provided to that Picker. The only instance in which we want to pass a 2nd param is if that picker is also controlling the value for a different input. In which case we would provide a custom callback (not yet supported, see this issue) and pass the inputID of the second input.

Copy link
Contributor

Choose a reason for hiding this comment

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

@rushatgabhane what are your thoughts about my comment above?

Copy link
Member Author

Choose a reason for hiding this comment

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

just started reading this, will get back soon

Copy link
Member Author

Choose a reason for hiding this comment

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

Passing an inputID as a second param allows inputA to manipulate the input value of the provided inputID (inputB).

Thank you, I understand the use of 2nd parameter better now.
I've updated the call to not pass the 2nd parameter.

@rushatgabhane rushatgabhane changed the title Rm set native props form Form - Migrate setNativeProps to state. Sep 16, 2022
@rushatgabhane
Copy link
Member Author

@luacmartins this is the PR you might be most interested in.

I've addressed your comments from #10934 (review)

@rushatgabhane

This comment was marked as outdated.

@parasharrajat
Copy link
Member

First, we should create a new issue instead of using #8503. This PR has nothing to do with Fabric architecture technically.

@rushatgabhane
Copy link
Member Author

@parasharrajat this PR is a prerequisite step to enabling fabric right?
because we're removing setNativeProps

@parasharrajat
Copy link
Member

I know but does it enable the Fabric architecture?

@rushatgabhane
Copy link
Member Author

Fair enough

@luacmartins luacmartins self-requested a review September 16, 2022 13:18
@rushatgabhane
Copy link
Member Author

rushatgabhane commented Sep 16, 2022

@parasharrajat @luacmartins are we going on the right track?

I feel like uncontrolled Form was so much cleaner. You didn't need to maintain values in state for pages that are using Form.

Is there a better approach?

@parasharrajat
Copy link
Member

That was one of the reasons, we use uncontrolled inputs. 😄

@luacmartins
Copy link
Contributor

I'm not sure there's much that we can do in this case. State seems to be the correct solution.

@rushatgabhane
Copy link
Member Author

rushatgabhane commented Sep 16, 2022

Cool, glad to hear we're on the right track.

P.S. Sorry but I'll add the screenshots to all the PRs within a week

@luacmartins
Copy link
Contributor

@rushatgabhane is this ready for review?

@rushatgabhane
Copy link
Member Author

ready for review

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

@rushatgabhane

Run npm run storybook and test picker functionalities. Make sure that we can edit the input and all values are updated accordinly.

NAB just noting that the callback provided in Picker's story is an empty lambda and the value is hardcoded, so selecting a different value and blurring the input resets the value to the previous one.

I did find an issue while testing though. In Profile > Timezone, manually selecting a different timezone and then checking Set my timezone automatically doesn't update the timezone to the correct one. The first value loaded also is incorrect for me, it should be Americas/Edmonton in my case.

Screen.Recording.2022-09-20.at.11.06.59.AM.mov

@rushatgabhane
Copy link
Member Author

Thanks, I'm working on it

return;
}

this.setState({hasSelfSelectedPronouns});
Copy link
Member Author

@rushatgabhane rushatgabhane Oct 6, 2022

Choose a reason for hiding this comment

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

NAB: This function is doing too many things.
But I'm not sure how to clean things up here 😕

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

@rushatgabhane I did notice the following bugs while testing:

  1. Picker does not work on Workspace > Connect bank account (Company step) > Company type and Workspace > Connect bank account (Company step) > Corporation state
error1.mov
  1. Picker is selecting the value before user clicks done on iOS:
error2.mov

Additionally, the bugs below seem to already be on prod 🤦

  1. Picker focus outline persists after blurring the input
  2. Address autofill does not automatically fill street and zip code

@luacmartins
Copy link
Contributor

Address autofill does not automatically fill street and zip code

This seems to be fixed with the changes in this PR 🎉

@rushatgabhane
Copy link
Member Author

rushatgabhane commented Oct 6, 2022

Picker is selecting the value before user clicks done on iOS

This was introduced by #11120 when I merged with main.

Fixed the iOS issue and #10437 as well by removing they key prop from BasePicker.

Screen.Recording.2022-10-07.at.2.06.38.AM.mov

Picker does not work on Workspace > Connect bank account (Company step) > Company type and Workspace > Connect bank account (Company step) > Corporation state

Sorry about that, I missed Pickers in CompanyStep page. I went through all other pages to make sure it isn't happening elsewhere.

@rushatgabhane
Copy link
Member Author

rushatgabhane commented Oct 6, 2022

Picker focus outline persists after blurring the input

This is resolved by this PR as well 🎉
(key prop for BasePicker was the culprit)

Screen.Recording.2022-10-07.at.2.24.54.AM.mov

@rushatgabhane
Copy link
Member Author

rushatgabhane commented Oct 6, 2022

@luacmartins could you please give this another look? All 4 bugs you had mentioned are now fixed.

@chiragsalian
Copy link
Contributor

Should we apply CP-staging label on this PR since it addresses a deploy blocker issue.

I think we should either CP this and then ask QA to regression test again since this changes a lot, OR ignore the deploy blocker for now since it's minor. Either way, I think regression testing should be done once this PR is on staging since its changes affect a number of components. Thoughts?

@luacmartins
Copy link
Contributor

@chiragsalian I think that we should remove the blocker label from that issue since it's a minor UI bug and have this go through the regular QA process and have it tested with full regression tests.

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

LGTM and tested well. Thanks for squashing all those bugs! Awesome job!

@luacmartins luacmartins merged commit a4be883 into Expensify:main Oct 7, 2022
@rushatgabhane
Copy link
Member Author

rushatgabhane commented Oct 7, 2022

Wohoo! 🎉
Thanks for the thorough review and helping me understanding form better

@OSBotify
Copy link
Contributor

OSBotify commented Oct 7, 2022

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @luacmartins in version: 1.2.13-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @yuwenmemon in version: 1.2.13-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

smrutiparida pushed a commit to autosave-app/App that referenced this pull request Oct 13, 2022
…ps-form

Form - Migrate setNativeProps to state.
Comment on lines +162 to +167
if (_.isUndefined(this.state.inputValues[inputID])) {
this.state.inputValues[inputID] = defaultValue;
}

if (!_.isUndefined(child.props.value)) {
this.state.inputValues[inputID] = child.props.value;
Copy link
Contributor

Choose a reason for hiding this comment

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

I just bumped into this code and noticed that we are mutating the state during rendering. I haven't seen any bug caused by this, but, as far as I know, a base assumption when working in React that the state won't mutate like this, otherwise, basic checks equality checks by reference become not reliable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any strong reason to mutate the state in this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you're right that this shouldn't be done. I think the state will change, but we won't re-render. AFAIK we should always be using setState cc @rushatgabhane

Copy link
Contributor

@aldo-expensify aldo-expensify Nov 28, 2022

Choose a reason for hiding this comment

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

It seems like this can be a technique to exactly do that, avoid re-rendering. In some cases it makes sense to avoid re-rendering.. but there are other ways of achieving this without having to mutate the state. There was a similar conversation here about a proposal suggesting to do this: #11086 (comment)

Summary:

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there any strong reason to mutate the state in this case?

Great question. I was aware that it isn't recommended to mutate state but chose to mutate because -

App/src/components/Form.js

Lines 166 to 167 in c72e7ac

if (!_.isUndefined(child.props.value)) {
this.state.inputValues[inputID] = child.props.value;

When value is passed as a prop, the parent component is expected to maintain (init and update) the state and cause a re-render.

If we had used setState, it'll cause an unnecessary re-render.

The form component also needs the correct inputValues to call the validate function.

this.validate(this.state.inputValues);

Copy link
Member Author

Choose a reason for hiding this comment

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

There are times when we need to trigger a re-render. eg: uncontrolled input changes. setState is called for inputValues

App/src/components/Form.js

Lines 178 to 181 in c72e7ac

onInputChange: (value, key) => {
const inputKey = key || inputID;
this.setState(prevState => ({
inputValues: {

Copy link
Member Author

@rushatgabhane rushatgabhane Nov 28, 2022

Choose a reason for hiding this comment

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

To have a "state" you can change without re-rendering, I think the recommended way is:
Class component: member variable

Agree. But why maintain another duplicate variable that we'll need to always keep in sync with inputValues?

Copy link
Contributor

Choose a reason for hiding this comment

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

To have a "state" you can change without re-rendering, I think the recommended way is:
Class component: member variable

Agree. But why maintain another duplicate variable that we'll need to always keep in sync with inputValues?

I haven't really gone in depth in this code, and I don't really plan to at the moment because of priorities, but even in the worse case of having duplicate variables, I still think it is better that doing something that is not expected in the framework.

Copy link
Member Author

@rushatgabhane rushatgabhane Nov 28, 2022

Choose a reason for hiding this comment

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

Cool, I'll raise a PR to clean this up (hopefully by end of this week)
This way I can dive deep and see if it causes any bugs.

note to self: deep clone everything

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, thanks guys!

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.

7 participants