我正在尝试根据props它所在的 React 组件的高度设置样式组件的高度。
我尝试了以下方法:
const Styled = styled.div`
height: ${props => props.height}
`
class Parent extends React.Component {
render() {
return (
<Styled height={this.props.height}/>
)
}
}
但不知何故它不起作用。有人可以帮我吗?我正在尝试做的最佳实践是什么?