Skip to content

refactor: segmented button typing #4686

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

Merged
merged 3 commits into from
Apr 22, 2025
Merged

Conversation

lukewalczak
Copy link
Member

Motivation

Add stricter typing for onValueChange in SegmentedButtons component to support union types in TypeScript projects.

Refreshing and rebasing the PR

Related issue

#4528

Test plan

jboteros and others added 3 commits April 22, 2025 13:46
Related to #4528

Add stricter typing for `onValueChange` in `SegmentedButtons` component to support union types in TypeScript projects.

* Modify `src/components/SegmentedButtons/SegmentedButtons.tsx` to accept a generic type parameter for the `value` and `onValueChange` props.
  * Update `ConditionalValue` type to use the generic type parameter.
  * Update `Props` type to use the generic type parameter.
* Update example files to demonstrate the usage of the stricter typing:
  * `example/src/Examples/SegmentedButtons/SegmentedButtonDefault.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonWithSelectedCheck.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonWithDensity.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonMultiselect.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonMultiselectIcons.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonCustomColorCheck.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonDisabled.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonMultiselectRealCase.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonOnlyIcons.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonOnlyIconsWithCheck.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonRealCase.tsx`
  * `example/src/Examples/SegmentedButtonsExample.tsx`
  * `example/src/Examples/ToggleButtonExample.tsx`

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/callstack/react-native-paper/issues/4528?shareId=XXXX-XXXX-XXXX-XXXX).
…cter typing

* Remove unnecessary filter function in `filteredData` calculation
* Fix ESLint error by updating code formatting
@lukewalczak lukewalczak changed the title Refactor/segmented button typing refactor: segmented button typing Apr 22, 2025
@callstack-bot
Copy link

Hey @lukewalczak, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

Copy link

The mobile version of example app from this branch is ready! You can see it here.

@lukewalczak lukewalczak merged commit 27a6556 into main Apr 22, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants