24jieqi / react-native-xiaoshu

🌈 React Native UI library
https://24jieqi.github.io/react-native-xiaoshu
Apache License 2.0
188 stars 21 forks source link

组件默认值配置 #22

Open onlyling opened 1 year ago

onlyling commented 1 year ago

组件默认值配置。

目的

使用

一般情况自定义默认属性。

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>
  )
}

更深入、高阶替换默认元素,例如 EmptyResult 的图标。

适配方式

参考 Blank

const Component = (props) => {
  const { a = '1', b = '2', ...restProps } = InitialValue.useInitialProps('Component', props)
}

已适配组件