-1
을 성능 우리가 얻거나 우리가 매개 변수에 destructure 경우 어떤 성능을 잃게 할 서명? example3 참조Destructuring 변수,</p> <pre><code>const color = props.color; </code></pre> <p></p> <pre><code>const { color } = props; </code></pre> 또한 <hr> <p>대 쓰기 사이의 성능 차이가있는 경우, 거기에
이 예제에서 example3이 함수를 작성하는 가장 좋은 방법이라고 생각하십니까?
예 기능적 구성 요소를 반응 : 코드가 등등/작게하다 컴파일 될 것이다
이const example1 = (props) => {
const color = props.color;
// I know I could also just write style={{ color: props.color }}
// but for arguments sake lets say I want to write it like this.
return <h1 style={{ color }}>Hello</h1>;
};
const example2 = (props) => {
const { color } = props;
return <h1 style={{ color }}>Hello</h1>;
};
const example3 = ({ color }) => {
return <h1 style={{ color }}>Hello</h1>;
};
베어링의 결과로 동일한 작업을 수행합니다 반작용으로, 코드가 transpiled됩니다
참고하여 코드가 실행되기 전에 추출되기 때문에이 세 가지 모두 매우 유사한/동일한 코드가 될 가능성이 큽니다. –
대부분의 경우 Google에서 답변을 얻으려면'js perf {feature}'가 가장 좋습니다 ... https://jsperf.com/destructuring/5를 참조하십시오. –
@TomFenech : JSX를 ES5로 옮기는 지 여부에 따라 달라집니다. ES2015 +. :-) –