๊ตฌ์ฑ ์์ ์ด๋ฆ์ด ํญ์ "์ ์ ์์"์ธ ์ด์ ๊ฐ ์์ต๋๊น?
๋ง์ผ์ ๊ฒฝ์ฐ๋ฅผ ๋๋นํ์ฌ browserify๋ฅผ ์ฌ์ฉํ๊ณ ์์ผ๋ฉฐ ์์ค๊ฐ ์ถ์๋์ง ์๊ณ ์ฐ๊ฒฐ๋ง ๋์ด ์์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ๋ณด์
๋๋ค.
์, ์ฌ๊ธฐ ๋น ๋ฅธ ์
๋ฐ์ดํธ๊ฐ ์์ต๋๋ค. ๊ตฌ์ฑ ์์๊ฐ ๋ค์๊ณผ ๊ฐ์ด ๋
ธ์ถ๋๋ฉด ์ด๋ฆ์ผ๋ก Unknown
๋ฉ๋๋ค.
exports.MyComponent = React.createClass({...});
๊ทธ๋ฌ๋ ์ด๊ฒ์ ๋ณ๊ฒฝํ๋ฉด ์๋ํ๊ธฐ ์์ํฉ๋๋ค.
var MyComponent = React.createClass({...});
exports.MyComponent = MyComponent;
ํ์ฅ ์์ค ์ฝ๋๋ฅผ ํ์ธํ์ง๋ง tagName
์ด๋ฉฐ ์ด๋ป๊ฒ ์ค์ ๋์ด ์๋์ง ์ ์ ์์ต๋๋ค.
JSX๋ฅผ ์ฌ์ฉํ์ง ์๋ ๊ฒฝ์ฐ ํด๋์ค์ displayName
์์ฑ์ ์ถ๊ฐํด์ผ ํฉ๋๋ค.
var MyComponent = React.createClass({
displayName: 'MyComponent',
...
});
JSX๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์๋์ผ๋ก ์ํ๋ฉ๋๋ค. ๋ถํํ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ ์์ต๋๋ค.
์, JSX๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค. ๋ฐ๋ผ์ ๋ค๋ฅธ ๋ฌธ์ ์ธ ๊ฒ ๊ฐ์ต๋๋ค. ๊ตฌ์ฑ ์์๊ฐ exports.ComponentName = React.createClass()
์ ์ธ๋ ๊ฒฝ์ฐ JSX ์ปดํ์ผ๋ฌ๋ displayName
๊ธฐ์ฌํ ์ ์์ต๋๋ค.
์ด๊ฒ์ ๊ทธ๊ฒ์ ๋ด๋นํ๋ ์ฝ๋์ ๋๋ค: https://github.com/facebook/react/blob/master/vendor/fbtransform/transforms/reactDisplayName.js#L37
JSX๋ ์ด๋ก ์ ์ผ๋ก ํ์๋ ์ง์ํ ์ ์์ต๋๋ค. ์ด ๋ฌธ์ ๋ ES6 ํด๋์ค ๋๋ ์ด์ ์ ์ฌํ ๊ฒ์ผ๋ก ์ด๋ํ๋ฉด ์ฌ๋ผ์ง๋๋ค.
tagName์ React ํต์ฌ์ ์๋ DOM ๊ตฌ์ฑ ์์์ ์ผ๋ถ์ ๋๋ค. displayName์ด ์์ต๋๋ค.
pull ์์ฒญ์ ๋ณด๋ด๋ ค๋ฉด ์ฌ๊ธฐ์ ์ํ๋ ํ์์ ์ถ๊ฐํ ์ ์์ต๋๋ค.
์๊ฒ ์ต๋๋ค. ๊ฐ์ฌํฉ๋๋ค. ์ง๊ธ์ ์๋ displayName
์ด ์๋ํฉ๋๋ค.
๋ด๊ฐ ์๊ฐํ ์ ์๋ ๋ชจ๋ ๊ฒฝ์ฐ์ ๋ํด ์ด๊ฒ์ ์์ ํด์ผ ํ๋ https://github.com/facebook/react/pull/799 ๋ฅผ ๋ฐฉ๊ธ ๋ง๋ค์์ต๋๋ค.
์ ๋ ํฌ๋กฌ ํ๋ฌ๊ทธ์ธ React Developer Tools
ํ๊ณ ์์ผ๋ฉฐ React ํธ๋ฆฌ๋ฅผ ๊ฒ์ฌํ ๋ ๊ตฌ์ฑ ์์์ ์ค์ ์ด๋ฆ ๋์ 'ํ๋ก์ ๊ตฌ์ฑ ์์'๊ฐ ํ์๋ฉ๋๋ค. webpack
๋ฌธ์ ์ผ ์ ์์ต๋๊น? 'displayName'์(๋ฅผ) ์ถ๊ฐํ๋ ค๊ณ ์๋ํ์ง๋ง ๊ทธ๋ ๊ฒ ํ์ง ์์์ต๋๋ค.
๋ค๋ฅธ ์ฌ๋์ด์ด ๋ฌธ์ ์ ๋ถ๋ช์ณค์ต๋๊น?
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ ๋ ํฌ๋กฌ ํ๋ฌ๊ทธ์ธ
React Developer Tools
ํ๊ณ ์์ผ๋ฉฐ React ํธ๋ฆฌ๋ฅผ ๊ฒ์ฌํ ๋ ๊ตฌ์ฑ ์์์ ์ค์ ์ด๋ฆ ๋์ 'ํ๋ก์ ๊ตฌ์ฑ ์์'๊ฐ ํ์๋ฉ๋๋ค.webpack
๋ฌธ์ ์ผ ์ ์์ต๋๊น? 'displayName'์(๋ฅผ) ์ถ๊ฐํ๋ ค๊ณ ์๋ํ์ง๋ง ๊ทธ๋ ๊ฒ ํ์ง ์์์ต๋๋ค.๋ค๋ฅธ ์ฌ๋์ด์ด ๋ฌธ์ ์ ๋ถ๋ช์ณค์ต๋๊น?