본문 바로가기
React

[React] 요소에 style 속성 추가

by 바나냥 2020. 11. 25.
const mystyles = {
   position: 'absolute',
} as React.CSSProperties;

 

<div style={mystyle}>not working</div>

 

 

stackoverflow.com/questions/46710747/type-string-is-not-assignable-to-type-inherit-initial-unset-fixe

 

Type 'string' is not assignable to type '"inherit" | "initial" | "unset" | "fixed" | "absolute" | "static" | "relative" | "stick

I get the following error in my application (npm 5.4.2, react 15.4, typescript 2.5.3, webpack 2.2.1, webpack-dev-server 2.4.1). This will work:

working&l...

 

stackoverflow.com

 

'React' 카테고리의 다른 글

map 한번만 렌더링하기 : useMemo  (0) 2020.12.08
컴포넌트 width 구하기  (0) 2020.12.07
React Slider 라이브러리  (0) 2020.11.10
styled component로 props 주기  (0) 2020.11.10
[Hooks] 4 : useCallback  (0) 2020.11.03

댓글