callstack / callstack/react-native-paper
Replace status prop with checked in ToggleButton component
- Dominant language
- TypeScript
- Stars
- 14.5k
- Forks
- 2.2k
- Avg merge
- 5d 23h
- Merged PRs (30d)
- 12
Description
**Is your feature request related to a problem? Please describe.**
The `ToggleButton` component currently uses a `status` prop with string values `checked` | `unchecked`. This adds unnecessary complexity for a binary state.
**Describe the solution you'd like**
Replace the `status` prop with a boolean `checked` prop.
Before:
```typescript
const ToggleButtonExample = () => {
const [status, setStatus] = React.useState('checked');
const onButtonToggle = () => {
setStatus(status === 'checked' ? 'unchecked' : 'checked');
};
return (
);
};
```
After:
```typescript
const ToggleButtonExample = () => {
const [isChecked, setIsChecked] = React.useState(true);
const onButtonToggle = () => {
setIsChecked(s => !s);
};
return (
);
};
```
**Additional context**
A boolean checked prop is simpler, clearer, and more consistent with common React patterns than using string values like 'checked' and 'unchecked'.
Contributor guide
Research direction
Locate the ToggleButton implementation and its usages in the react-native-paper codebase, then inspect how the current status prop is typed and consumed. The work is done when the component and its callers consistently use checked as a boolean instead of status string values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- frontend, mobile
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100