react-native-xiaoshu
react-native-xiaoshu copied to clipboard
组件默认值配置
组件默认值配置。
目的
- 统一预设默认值,避免每个业务点手动配置
- 避免业务二次封装组件后与内部复用的组件表现不一致
使用
一般情况自定义默认属性。
import React from 'react'
import { Provider, Button } from '@fruits-chain/react-native-xiaoshu'
const initialValue = {
Button: {
size: 'm',
hairline: true,
round: true,
},
}
const App: React.FC = () => {
return (
<Provider initialValue={initialValue}>
<Button text="普通按钮" type="primary" />
</Provider>
)
}
更深入、高阶替换默认元素,例如 Empty
、Result
的图标。
适配方式
参考 Blank
const Component = (props) => {
const { a = '1', b = '2', ...restProps } = InitialValue.useInitialProps('Component', props)
}
已适配组件
- [x] Blank
- [x] BottomBar
- [x] Button
- [x] ButtonBar
- [x] CellGroup
- [x] Cell
- [x] Empty
- [x] Loading
- [x] ProgressPage