Reactjs react性能问题中的样式(组件)和样式(标记名)有什么不同?
我不熟悉样式化组件,我想知道在react的性能问题上,styledcomponent和styledtagname有什么不同 styledtagname const StyledP=styled'p'`` 导出常量StyledComponent=props=> {props.name} 样式组件 常量FunctionalComponent=props=>Reactjs react性能问题中的样式(组件)和样式(标记名)有什么不同?,reactjs,styled-components,Reactjs,Styled Components,我不熟悉样式化组件,我想知道在react的性能问题上,styledcomponent和styledtagname有什么不同 styledtagname const StyledP=styled'p'`` 导出常量StyledComponent=props=> {props.name} 样式组件 常量FunctionalComponent=props=> {props.name} 导出常量StyledComponent=styledFunctionalComponent` ` 我看了这张照片
{props.name}
导出常量StyledComponent=styledFunctionalComponent` ` 我看了这张照片 并发现我是否使用了styledcomponent。 但我不知道react的性能问题。有人能解释一下吗?如果目标是一个组件,它是同一个API,还需要一些额外的检查。从样式化构造函数中提取: 总结如下: 使用派生样式化组件的规则扩展基本样式化组件的属性和规则。 如果是嵌套的styledComponent扩展,请保留组件列表。 保留原始目标元素dom字符串,作为所有扩展的目标。
const isTargetStyledComp = isStyledComponent(target);
// fold the underlying StyledComponent attrs up (implicit extend)
const finalAttrs =
// $FlowFixMe
isTargetStyledComp && target.attrs
? Array.prototype.concat(target.attrs, attrs).filter(Boolean)
: attrs;
// fold the underlying StyledComponent rules up (implicit extend)
const componentStyle = new ComponentStyle(
isTargetStyledComp ? target.componentStyle.rules.concat(rules) : rules,
finalAttrs,
styledComponentId
);
// $FlowFixMe
WrappedStyledComponent.foldedComponentIds = isTargetStyledComp
? // $FlowFixMe
Array.prototype.concat(target.foldedComponentIds, target.styledComponentId)
: EMPTY_ARRAY;
WrappedStyledComponent.target = isTargetStyledComp ? target.target : target;