Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

[BUG] 封装Button组件时使用展开运算符对size属性无效 #375

Closed
WhiteMinds opened this issue Nov 18, 2019 · 1 comment · Fixed by #379
Closed

[BUG] 封装Button组件时使用展开运算符对size属性无效 #375

WhiteMinds opened this issue Nov 18, 2019 · 1 comment · Fixed by #379
Labels
bug Something isn't working

Comments

@WhiteMinds
Copy link
Contributor

WhiteMinds commented Nov 18, 2019

bug 描述
封装Button组件时使用了展开运算符, <RMButton {...props} />
测试了一部分属性, 比如className, plain等都是正常的, 但size属性无效

复现步骤
运行复现代码后, 查看开发者工具中的Button, 是<button aria-disabled="false" hover-start-time="0" hover-stay-time="0" type="primary" role="button">, 并没有size.
plain也未显示于开发者工具中, 但实际上生效了, 不知道为什么开发者工具上不显示.

期望结果
使size能够正常传播

复现代码
components/Button/index.tsx

import { Button as RMButton } from 'remax/wechat'
import { ButtonProps as RMButtonProps } from 'remax/esm/adapters/wechat/components/Button'
import * as React from 'react'

export interface ButtonProps extends RMButtonProps {
	children?: React.ReactNode
}

export const Button = (props: ButtonProps) => {
	return (
		<RMButton {...props}>
			{props.children}
		</RMButton>
	)
}

pages/index/index.tsx

import { Button } from '@/components/Button'
import { View } from 'remax/wechat'
import * as React from 'react'

export default () => {
	return (
		<View>
			<Button type="primary" size="mini" plain={true}>Test</Button>
		</View>
  )
}

版本信息:

  • remax 版本: [1.0.1]
  • 手机型号 [未测试]
  • 小程序端 [微信小程序]
  • 小程序版本[微信开发者工具]
  • 开发环境 [mac OS]

其他信息
Lark20191118180919

@WhiteMinds WhiteMinds added the bug Something isn't working label Nov 18, 2019
@WhiteMinds
Copy link
Contributor Author

另外, 将代码改为<RMButton {...props} size={props.size}>的话, 是可以工作的, 这是我目前的临时方案

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant