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

POC: pulling redux up out of v1 keypad #480

Closed
wants to merge 7 commits into from
Closed

Conversation

handeyeco
Copy link
Contributor

@handeyeco handeyeco commented Apr 18, 2023

Summary:

This is a WIP/POC of what things might look like if we were to pull Redux up out of the v1 keypad.

It's not working as-is and at this point I think it's a dead end (and a mistake on my part to have pursued it).

Thoughts:

  • I don't think we're doing anything that really necessitates using Redux and we violate come of the core rules of Redux (such as having side-effects or having complex state machines within the Redux store).
  • As far as I understand it, we're basically using it to avoid prop drilling. There's also some GestureManager logic that's tied to the store, but this is part of the Redux anti-pattern and shouldn't be there anyway.
  • Redux mostly seems to be just for the Keypad. The highest component using Redux was the KeypadContainer component.

I think we could clean this up quite a bit using Context/Hooks, but given that this all seems to be for the Keypad and we're going to look at replacing the Keypad with v2...I'm not sure we need to keep trying to refactor this.

Issue: LC-729

Test plan:

@handeyeco handeyeco self-assigned this Apr 18, 2023
@changeset-bot
Copy link

changeset-bot bot commented Apr 18, 2023

⚠️ No Changeset found

Latest commit: b736624

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@handeyeco handeyeco changed the title remove redux fro touchable-keypad-button POC: pulling redux up out of v1 keypad Apr 18, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 18, 2023

Size Change: +38 B (0%)

Total Size: 650 kB

Filename Size Change
packages/math-input/dist/es/index.js 59 kB +38 B (0%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 38 kB
packages/kmath/dist/es/index.js 4.13 kB
packages/perseus-editor/dist/es/index.js 114 kB
packages/perseus-error/dist/es/index.js 705 B
packages/perseus-linter/dist/es/index.js 21.2 kB
packages/perseus/dist/es/index.js 397 kB
packages/pure-markdown/dist/es/index.js 3.65 kB
packages/simple-markdown/dist/es/index.js 12.6 kB

compressed-size-action

Copy link
Contributor

@kevinbarabash kevinbarabash left a comment

Choose a reason for hiding this comment

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

I worry that we're swapping one issue for another with the move from Redux to prop drilling. I think that much of the state that is currently being store at the top-level could be moved into some of the components. For instance, why do we need to know about the state of the button echos outside of the buttons themselves. Potentially we could also have the popover state live closer to where it's used.

Comment on lines +22 to +23
heightPx: number;
widthPx: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

style nit: we don't normally put suffix on height and width. The assumption that React uses is that if the value doesn't contain a unit of measure that the value is assumed to be in pixels.

Comment on lines +369 to +370
heightPx: state.layout.buttonDimensions.heightPx,
widthPx: state.layout.buttonDimensions.widthPx,
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: instead of passing this around as separate values everywhere, maybe combine these into a data structure, e.g. Dimensions that can be passed around.

Comment on lines 31 to 47
interface ReduxProps {
active?: boolean;
active: boolean;
extraKeys?: ReadonlyArray<string>;
keypadType?: KeypadType;
layoutMode?: keyof typeof LayoutModes;
navigationPadEnabled?: boolean;
currentPage: number;
cursorContext?: CursorContext;
dynamicJumpOut: boolean;
paginationEnabled: boolean;
echoes: ReadonlyArray<Echo>;
popover: Popover | null;
heightPx: number;
widthPx: number;
gestureManager: GestureManager;
gestureFocus: Key | null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

question: is the goal to eventually get rid of this use of redux as well?

Comment on lines +27 to +28
heightPx: number;
widthPx: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: people might think that this specifies the width/height of the keypad when in reality it's specifying the dimensions of the buttons. Maybe these could be group together and the prop renamed, e.g.

buttonDimensions: Dimensions,

or

buttonSize: Size,

handeyeco added a commit that referenced this pull request May 9, 2023
## Summary:
As  part of [this PR](#480) I started to understand `touchable-keypad-button`. I'm not sure we'll want to merge that PR, so just in case I decided to make this PR that takes this opportunity to type the component.

Part of: LC-746

## Test plan:
Logic shouldn't change, only types

Author: handeyeco

Reviewers: handeyeco, jeremywiebe, kevinbarabash

Required Reviewers:

Approved By: jeremywiebe

Checks: ✅ finish_coverage, ✅ Publish npm snapshot (ubuntu-latest, 16.x), ✅ Extract i18n strings (ubuntu-latest, 16.x), ✅ Cypress Coverage (ubuntu-latest, 16.x), ✅ Lint, Typecheck, and Test (ubuntu-latest, 16.x), ✅ Check builds for changes in size (ubuntu-latest, 16.x), ✅ Jest Coverage (ubuntu-latest, 16.x), ✅ gerald, ✅ Check for .changeset file (ubuntu-latest, 16.x), ✅ .github/dependabot.yml

Pull Request URL: #483
@handeyeco
Copy link
Contributor Author

We decided to not use Redux in v2 keypad

@handeyeco handeyeco closed this Jun 26, 2023
@handeyeco handeyeco deleted the LC-729/pull-up-redux branch January 10, 2024 15:51
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.

2 participants