【发布时间】:2020-11-29 07:06:12
【问题描述】:
我正在尝试在带有 styled-component 和 react-native-web 的 monorepos 中使用 react-responsive。
我有一个像我的 ui lib 这样的工作区,我这样定义我的组件:
import styled from 'styled-components/native';
import { theme } from '@components/theme';
import MediaQuery from 'react-responsive';
interface CardProps {
children: React.ReactNode;
tag: string;
}
const Card = (props: CardProps) => {
console.log("Card -> props", props)
return (
<Container>
<MediaQuery minDeviceWidth={1000}>
<Tag>'blablabla</Tag>
</MediaQuery>
<TagContainer>
<Tag>{props.tag}</Tag>
</TagContainer>
<MainContent>{props.children}</MainContent>
</Container>
);
}
我这样定义风格:
const Container = styled.View`
display: flex;
flexDirection: column;
minWidth: ${theme.width.minCard};
maxWidth: ${theme.width.maxCard};
height: ${theme.height.card};
boxShadow: 0 0 10px ${theme.colors.primaryGrey};
border: 1px solid ${theme.colors.primaryYellow};
borderRadius: ${theme.borderRadius.rectangular};
marginBottom: ${theme.margins.medium};
`;
const TagContainer = styled.View`
display: flex;
flexDirection: row-reverse;
`;
我正在尝试在位于另一个工作区的 react-native 应用程序中使用此组件,如下所示:
return (
<View>
<Specialist
key={psychologist.uuid}
img={psychologist.avatar.url}
name={psychologist.fullname}
job={psychologist.job_name}
description={psychologist.description}
/>
</View>
);
每次,我都发现自己被这个错误阻止:
但是我的组件确实是一个功能组件...
有什么想法吗?
【问题讨论】:
标签: react-native media-queries styled-components react-native-web