๐Ÿ’ก ํ”„๋ก ํŠธ์—”๋“œ

[React: ์˜ค๋ฅ˜] Warning: Invalid DOM property `for`. Did you mean `htmlFor`?

์˜ˆ์ง„-D 2023. 3. 8. 22:28

์˜ค๋ฅ˜ ๋ฐœ์ƒ

๋ฆฌ์•กํŠธ๋กœ ํ”„๋กœ์ ํŠธ๋ฅผ ๊ฐœ๋ฐœํ•˜๋˜ ๋„์ค‘ JSX label์„ ์‚ฌ์šฉํ–ˆ๋Š”๋ฐ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋–ด์Šต๋‹ˆ๋‹ค.

Warning: Invalid DOM property `for`. Did you mean `htmlFor`?

 

label์—์„œ for ๋Œ€์‹  htmlFor๋ฅผ ๊ถŒ๊ณ ํ•˜๋Š” ๋ชจ์Šต

ํ”„๋กœ๊ทธ๋žจ์ด ๋ฉˆ์ถœ ์ •๋„์˜ ์˜ค๋ฅ˜๋Š” ์•„๋‹ˆ์—ˆ์ง€๋งŒ ๋ฌด๋ ค ์ฝ˜์†”์ฐฝ์— ๋„์›Œ์ค„ ์ •๋„์˜ ์—๋Ÿฌ์ด๋‹ˆ ํ•ด๊ฒฐํ•ด์•ผ ํ–ˆ์–ด์š”. ๋ฌผ๋ก  ์นœ์ ˆํ•˜๊ฒŒ๋„ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•๊นŒ์ง€ ์ถ”์ฒœ์„ ํ•ด์ฃผ๊ณ  ์žˆ์ง€๋งŒ, ์™œ ์˜ค๋ฅ˜๊ฐ€ ๋–ด๋Š”์ง€ ์•Œ๊ณ  ์‹ถ์—ˆ์Šต๋‹ˆ๋‹ค.

 

์˜ค๋ฅ˜ ์ด์œ 

for์€ Javascript์˜ keyword์ด๊ธฐ ๋•Œ๋ฌธ์— JSX์—์„œ ์ด๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— label์—์„œ๋„ for๋Œ€์‹  htmlFor๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ๋กœ ๊ฒฐ์ •ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

ํ•ด๊ฒฐ๋ฐฉ๋ฒ•

label ํƒœ๊ทธ์—์„œ for ๋Œ€์‹  htmlFor๋กœ ๋ณ€๊ฒฝํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

์ฐธ๊ณ 

https://stackoverflow.com/questions/59924585/im-getting-an-error-using-react-invalid-dom-property-for-did-you-mean-htm

 

I'm getting an error using React: "Invalid DOM property `for`. Did you mean `htmlFor`"

I'm creating a simple CRUD app using React for my front-end, and I'm having trouble with this error: app.js:21988 Warning: Invalid DOM property `for`. Did you mean `htmlFor`? Here's my code: import

stackoverflow.com