Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 样式化组件v3的主题对象为空_Reactjs_Styled Components - Fatal编程技术网

Reactjs 样式化组件v3的主题对象为空

Reactjs 样式化组件v3的主题对象为空,reactjs,styled-components,Reactjs,Styled Components,升级到styled后-components@latest(3.1.0)启动应用程序时,会抛出以下错误: 未捕获类型错误:无法读取未定义的属性“margin” 检查后,主题对象在如下定义的组件中看起来是空的: export const Form=styled.Form` ${({theme})=>theme.layout.margin.all.small}; `; 这里记录theme会返回{},但是在jsx中的级别,主题会按预期记录,并包含所有值 如果我降级到2.4.0,它运行良好,正如预期的

升级到styled后-components@latest(3.1.0)启动应用程序时,会抛出以下错误:

未捕获类型错误:无法读取未定义的属性“margin”

检查后,主题对象在如下定义的组件中看起来是空的:


export const Form=styled.Form`
${({theme})=>theme.layout.margin.all.small};
`;

这里记录
theme
会返回
{}
,但是在jsx中的
级别,主题会按预期记录,并包含所有值


如果我降级到2.4.0,它运行良好,正如预期的那样

这可能有多种原因,但我认为这与v3无关,因为主题API没有改变


您是否在升级时引入了循环依赖项?

结果发现,样式化组件的多个版本相互冲突

删除重复项并按预期工作