Skip to content

Commit

Permalink
[#459] Fix: 너무 많은 클래스가 생기는 현상 방지
Browse files Browse the repository at this point in the history
styled-componenet prop이 아주 빠르게 변하면서 200개 이상의 클래스가 생성됐다는 경고가 생겼습니다.
해당 경고문에서 권장하는 방법대로 수정하였습니다.
  • Loading branch information
giwan-dev committed Feb 6, 2020
1 parent 9adadc8 commit 3d0b955
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions packages/slider/src/handle.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import React from 'react'
import styled, { StyledComponentProps } from 'styled-components'

const HandleContainer = styled.div<{ percent: number }>`
const HandleContainer = styled.div.attrs<{ percent: number }>(
({ percent }) => ({
style: {
left: `${percent}%`,
},
}),
)`
position: absolute;
box-sizing: border-box;
left: ${({ percent }) => percent}%;
width: 70px;
height: 90px;
transform: translate(-50%, -50%);
Expand Down
11 changes: 8 additions & 3 deletions packages/slider/src/track.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import React from 'react'
import styled, { StyledComponentProps } from 'styled-components'

export const TrackContainer = styled.div<{ left: number; right: number }>`
export const TrackContainer = styled.div.attrs<{ left: number; right: number }>(
({ left, right }) => ({
style: {
left: `${left}%`,
right: `${100 - right}%`,
},
}),
)`
position: absolute;
left: ${({ left }) => left}%;
right: ${({ right }) => 100 - right}%;
padding: 20px 0;
margin-top: -20px;
`
Expand Down

0 comments on commit 3d0b955

Please sign in to comment.