callstack / callstack/react-native-paper
Replace status prop with checked in ToggleButton component
- 主要语言
- TypeScript
- 星标
- 14.5k
- 派生
- 2.2k
- 平均合并
- 5 天 23 小时
- 30 天内合并 PR
- 12
描述
**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'.
贡献指南
调研方向
在 react-native-paper 代码库中找到 ToggleButton 的实现及其使用位置,然后检查当前 status prop 的类型定义和使用方式。当组件及其调用方都统一使用布尔值 checked,而不是 status 字符串值时,工作即完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- react-native, typescript
- 领域
- frontend, mobile
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 50/100