I noticed that new Emotion 's are getting outputted in the every time I update my style dynamically.
Follow an example in which every time DynamicStyleContainer is clicked, a new is created in the head.
import { css } from "@emotion/core";
import styled from "@emotion/styled";
import React from "react";
import _ from "lodash";
const app = css`
width: 1000px;
background-color: pink;
height: 100px;
`;
const dynamicStyle = (props) => ({
width: props.appDimensions + "px",
});
const DynamicStyleContainer = styled.div`
${dynamicStyle};
`;
export default function App() {
const [appDimensions, setAppDimensions] = React.useState(1);
const increase = () => {
setAppDimensions(appDimensions + 1);
};
return (
<DynamicStyleContainer appDimensions={appDimensions}>
<div id="app" css={app} onClick={increase}></div>
</DynamicStyleContainer>
);
}
Inspecting the head element:
I read the documentation and some examples and all seem to do something like this. Is this a normal behavior?
