์๋์ฒ๋ผ props๋ฅผ ํผ์นจ์ฐ์ฐ์(spread operator)๋ฅผ ์ฐ๋ ๊ฒ๋ ESLint์์ ๊ถ์ฅํ๋ ํจํด์ ์๋๋ค. ์ฝ๋์ ๊ฐ๋ ์ฑ๊ณผ ์ ์ง๋ณด์๋ฅผ ์ํด์๋ ์ด๋ค prop์ ๋ด๋ ค์ฃผ๊ณ ์๋์ง ์ผ์ผ์ด ๋ช ์ํ๋ ๊ฒ์ด ์ข๋ค.
Disallow JSX props spreading (react/jsx-props-no-spreading)
Enforces that there is no spreading props for any JSX attribute. This enhances readability of code by being more explicit about what props are received by the component. It is also good for maintainability by avoiding passing unintentional extra props and alllowing react to emit warnings when invalid HTML props are passed to HTML elemements.
<App {...props}>
<MyCustomComponent {...props} some_other_prop={some_other_prop} />
</App>
์๋์ฒ๋ผ props๋ฅผ ๋ช ์ํด์ฃผ์.
const { src, alt } = props;
const { one_prop, two_prop } = otherProps;
<MyCustomCOmponent one_prop={one_prop} two_prop={two_prop} />
<img src={src} alt={alt} />
Rule Options
"react/jsx-props-no-spreading": [<enabled>, {
"html": "ignore" | "enforce",
"custom": "ignore" | "enforce",
"explicitSpread": "ignore" | "enforce",
"exceptions": [<string>]
}]
...
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md