Html-react-parser: attributeToProps์— ๋Œ€ํ•œ ์ž˜๋ชป๋œ ๋ฐ˜ํ™˜ ์œ ํ˜•

์— ๋งŒ๋“  2021๋…„ 04์›” 16์ผ  ยท  5์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: remarkablemark/html-react-parser

์„ค๋ช…

attributes-to-props.d.ts ํŒŒ์ผ์—์„œ attributesToProps ํ•จ์ˆ˜์˜ ๋ฐ˜ํ™˜ ์œ ํ˜•์€ String ํ•ญ๋ชฉ์ด ์žˆ๋Š” Object ์ž…๋‹ˆ๋‹ค.

https://github.com/remarkablemark/html-react-parser/blob/80bbea06fac6825f2667060f979fbd54b407e748/lib/attributes-to-props.d.ts#L3 -L4

๊ทธ๋Ÿฌ๋‚˜ attributesToProps ํ•จ์ˆ˜์—์„œ setStyleProp ๋Š” CSSInline ๋ฅผ StyleObject ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ํ˜ธ์ถœ์ž…๋‹ˆ๋‹ค.

https://github.com/remarkablemark/html-react-parser/blob/80bbea06fac6825f2667060f979fbd54b407e748/lib/attributes-to-props.js#L62

ํ•จ์ˆ˜์˜ ๋ฐ˜ํ™˜์€์ด๋‹ค StyleObject ๊ฐ€ ์•„๋‹Œ String .

https://github.com/remarkablemark/html-react-parser/blob/80bbea06fac6825f2667060f979fbd54b407e748/lib/utilities.js#L76 -L87

CSSProperty ๋ฅผ ์–ป์œผ๋ ค๋Š” ๊ฒฝ์šฐ ์ด ์ž…๋ ฅ ์˜ค๋ฅ˜์˜ ๊ฒฐ๊ณผ๋Š” ์˜ค๋ฅ˜์ž…๋‹ˆ๋‹ค.

Capture dโ€™eฬcran 2021-04-16 aฬ€ 10 42 51

์˜ˆ์ƒ๋˜๋Š” ๋™์ž‘

attributes-to-props.d.ts ์—…๋ฐ์ดํŠธ:

export type Attributes = Record<string, string>; 
export type Props = Record<string, string> & {
  style: Record<string, string>;
}; 

๋ชจ๋“  5 ๋Œ“๊ธ€

์ด ๋ฌธ์ œ @EoleO๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. PR์„ ์‹œ์ž‘ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?

@EoleO ๋ฆฌ๋ทฐ #245

๊ฒŒ์‹œ๋œ v1.2.6 :

npm :

npm i [email protected]

์›์‚ฌ :

yarn add [email protected]

์‘๋‹ตํ•ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

@EoleO ๋ฌผ๋ก  ์—ฌ์ „ํžˆ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ์–ธ์ œ๋“ ์ง€ ๋‹ค์‹œ ์—ฌ์‹ญ์‹œ์˜ค.

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰