首页 > 解决方案 > Emotion/Styled 创建了大量独特的类名

问题描述

我正在使用 React 创建一个浏览器游戏,背景由单独的 Tile 组件组成。就我而言,这些往往具有相同的风格;

const BaseTile = styled.div`
  width: 40px;
  height: 40px;
  position: absolute;
`;

但是,在每个 Tile 上,背景图像可能不同,并且变换值总是不同的。结果,Emotion/Styled 创建了大量的类名。我担心这可能会成为性能问题。对我的用例的任何建议将不胜感激。

例子

标签: reactjsstyled-componentsemotion

解决方案


推荐阅读