如何使用gluestack-ui类型

问题描述 投票:0回答:1

我正在使用名为(gluestack-ui)的新组件库。

我正在使用打字稿,我想在我的组件中使用“Box”组件道具类型接口。

找不到,接口有导出吗?

import { Box } from '@gluestack-ui/themed'

export interface PaperProps extends PropsWithChildren  {}

export default function Paper({ children }: PaperProps) { 
  return <Box>{children}</Box>
}

以material-ui为例,您可以:

import { Box, type BoxProps } from '@mui/material'

我可以例如:

export interface PaperProps extends PropsWithChildren & BoxProps  {}

我怎样才能用gluestack-ui做同样的事情?

react-native native-base gluestack
1个回答
0
投票

您可以使用 React 中的

ComponentProps
来执行此操作。

import { ComponentProps } from 'react'
import { Box } from '@gluestack-ui/themed'

export interface PaperProps extends ComponentProps<typeof Box>  {}

export default function Paper({ children }: PaperProps) { 
  return <Box>{children}</Box>
}

字体:https://stackoverflow.com/a/55220191/11705481

© www.soinside.com 2019 - 2024. All rights reserved.