语义 UI React:如果使用枚举,如何动态更改组件属性?
Semantic UI React: How to change components properties dynamically if they used enum?
事情是这样的,我正在尝试使用状态来更改语义 UI 动态地反应 (v 0.81.1) 组件,但是当真或假时它很简单,但如果需要特定值, 我不能使用它们
状态值
state = {
gridColumnWidth: 14
}
网格使用
<Grid>
<Grid.Row>
<Grid.Column width={this.state.gridColumnWidth}>
<Message header='Header'content='Content'/>
</Grid.Column>
</Grid.Row>
</Grid>
错误
Type '{ children: Element; width: number; }' is not assignable to type 'IntrinsicAttributes & GridColumnProps & { children?: ReactNode; }'.
Type '{ children: Element; width: number; }' is not assignable to type 'GridColumnProps'.
Types of property 'width' are incompatible.
Type 'number' is not assignable to type '2 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 1 | 11 | 12 | 13 | 14 | 15 | 16 | "1" | "2" | "3" | "4" | "5...'.
有什么技巧吗?
看起来,语义 ui React 并不总是希望与 stats 和 required const 值一起工作,例如 props。
<Grid>
<Grid.Row>
<Grid.Column width={this.props.width}>
<Message header='Header'content='Content'/>
</Grid.Column>
</Grid.Row>
</Grid>
这有帮助,也许对以后的人有用。
事情是这样的,我正在尝试使用状态来更改语义 UI 动态地反应 (v 0.81.1) 组件,但是当真或假时它很简单,但如果需要特定值, 我不能使用它们
状态值
state = {
gridColumnWidth: 14
}
网格使用
<Grid>
<Grid.Row>
<Grid.Column width={this.state.gridColumnWidth}>
<Message header='Header'content='Content'/>
</Grid.Column>
</Grid.Row>
</Grid>
错误
Type '{ children: Element; width: number; }' is not assignable to type 'IntrinsicAttributes & GridColumnProps & { children?: ReactNode; }'.
Type '{ children: Element; width: number; }' is not assignable to type 'GridColumnProps'.
Types of property 'width' are incompatible.
Type 'number' is not assignable to type '2 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 1 | 11 | 12 | 13 | 14 | 15 | 16 | "1" | "2" | "3" | "4" | "5...'.
有什么技巧吗?
看起来,语义 ui React 并不总是希望与 stats 和 required const 值一起工作,例如 props。
<Grid>
<Grid.Row>
<Grid.Column width={this.props.width}>
<Message header='Header'content='Content'/>
</Grid.Column>
</Grid.Row>
</Grid>
这有帮助,也许对以后的人有用。