Page MenuHomePhabricator

[web] Move `onChangeAccountPassword` up from `ThreadSettingsModal` to `ConnectedThreadSettingsModal`
ClosedPublic

Authored by atul on Apr 18 2022, 3:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Sep 7, 4:56 AM
Unknown Object (File)
Mon, Aug 26, 3:11 PM
Unknown Object (File)
Sun, Aug 25, 11:23 AM
Unknown Object (File)
Tue, Aug 20, 11:53 AM
Unknown Object (File)
Tue, Aug 20, 11:53 AM
Unknown Object (File)
Sun, Aug 18, 8:18 PM
Unknown Object (File)
Sat, Aug 17, 5:12 PM
Unknown Object (File)
Sat, Aug 17, 5:12 PM

Details

Summary

Move onChangeAccountPassword out from inner class component to outer "Connected" functional component.

As part of the work to refactor ThreadSettingsModal... specifically to turn it into a functional component.


Depends on D3768

Test Plan
  1. Open ThreadSettingsModal
  2. Change account password under delete tab
  3. Log values in onChangeAccountPassword to ensure that the state continues to change as expected

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

atul requested review of this revision.Apr 18 2022, 3:30 PM
tomek added inline comments.
web/modals/threads/thread-settings-modal.react.js
457–463 ↗(On Diff #11650)

When a callback doesn't depend on anything, we can define the function outside the component. But on the other hand, it will break the flow of the code, so it's not necessarily worth it.

This revision is now accepted and ready to land.Apr 21 2022, 3:11 AM
web/modals/threads/thread-settings-modal.react.js
457–463 ↗(On Diff #11650)

Even though there aren't any dependencies, doesn't using React.useCallback provide referential equality when passed to the inner ThreadSettingsModal class component?

web/modals/threads/thread-settings-modal.react.js
457–463 ↗(On Diff #11650)

When a function is defined in global scope, it never changes and is always equal to itself. It's true that callback provide the equality, but it is only needed when a function is redefined, e.g. in render function.