You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> `React.PropTypes` has moved into a different package since React v15.5. Please use [the `prop-types`library instead](https://www.npmjs.com/package/prop-types).
11
+
> `React.PropTypes`는 React v15.5부터 다른 패키지로 이동하였습니다. 대신 [`prop-types`라이브러리를](https://www.npmjs.com/package/prop-types) 사용하시길 바랍니다.
12
12
>
13
-
>We provide [a codemod script](/blog/2017/04/07/react-v15.5.0.html#migrating-from-reactproptypes)to automate the conversion.
13
+
>우리는 변환을 자동화하기 위하여 [codemod 스크립트를](/blog/2017/04/07/react-v15.5.0.html#migrating-from-reactproptypes)제공하고 있습니다.
14
14
15
-
As your app grows, you can catch a lot of bugs with typechecking. For some applications, you can use JavaScript extensions like [Flow](https://flow.org/)or[TypeScript](https://www.typescriptlang.org/) to typecheck your whole application. But even if you don't use those, React has some built-in typechecking abilities. To run typechecking on the props for a component, you can assign the special `propTypes` property:
15
+
당신의 앱이 커짐에 따라 타입 확인을 통하면 많은 버그를(bug) 잡을 수 있습니다. 특정 애플리케이션에서는 전체 애플리케이션의 타입 확인을 위하여 [Flow](https://flow.org/)또는[TypeScript](https://www.typescriptlang.org/)와 같은 JavaScript 도구(Extensions)를 사용할 수 있습니다. 당신이 이러한 것들을 사용하지 않더라도 React는 내장된 타입 확인 기능들을 가지고 있습니다. 컴포넌트의 props에 타입 확인을 하려면 다음과 같이 특별한 프로퍼티인 propTypes를 선언할 수 있습니다.
16
16
17
17
```javascript
18
18
importPropTypesfrom'prop-types';
@@ -30,18 +30,18 @@ Greeting.propTypes = {
30
30
};
31
31
```
32
32
33
-
`PropTypes` exports a range of validators that can be used to make sure the data you receive is valid. In this example, we're using `PropTypes.string`. When an invalid value is provided for a prop, a warning will be shown in the JavaScript console. For performance reasons, `propTypes` is only checked in development mode.
33
+
`PropTypes`는 전달받은 데이터의 유효성을 검증하기 위해서 다양한 유효성 검사기(Validator)를 내보냅니다. 아래 예시에서는 `PropTypes.string`을 사용하게 될 것입니다. prop에 유효하지 않은 값이 전달 되었을 때, 경고문이 JavaScript 콘솔을 통해 보일 것입니다. `propTypes`는 성능상의 이유로 개발 모드(Development mode) 에서만 확인될 것입니다.
34
34
35
35
### PropTypes {#proptypes}
36
36
37
-
Here is an example documenting the different validators provided:
37
+
아래는 제공된 서로 다른 유효성 검사기들을 보여주는 예시입니다.
38
38
39
39
```javascript
40
40
importPropTypesfrom'prop-types';
41
41
42
42
MyComponent.propTypes= {
43
-
//You can declare that a prop is a specific JS type. By default, these
44
-
//are all optional.
43
+
//prop가 특정 JS 형식임을 선언할 수 있습니다.
44
+
//이것들은 기본적으로 모두 선택 사항입니다.
45
45
optionalArray:PropTypes.array,
46
46
optionalBool:PropTypes.bool,
47
47
optionalFunc:PropTypes.func,
@@ -50,50 +50,49 @@ MyComponent.propTypes = {
50
50
optionalString:PropTypes.string,
51
51
optionalSymbol:PropTypes.symbol,
52
52
53
-
//Anything that can be rendered: numbers, strings, elements or an array
54
-
//(or fragment) containing these types.
53
+
//랜더링 될 수 있는 것들은 다음과 같습니다.
54
+
//숫자(numbers), 문자(strings), 엘리먼트(elements), 또는 이러한 타입들(types)을 포함하고 있는 배열(array) (혹은 배열의 fragment)
55
55
optionalNode:PropTypes.node,
56
56
57
-
//A React element.
57
+
// React 엘리먼트.
58
58
optionalElement:PropTypes.element,
59
59
60
-
//You can also declare that a prop is an instance of a class. This uses
61
-
// JS's instanceof operator.
60
+
//prop가 클래스의 인스턴스임을 선언할 수 있습니다.
61
+
//이 경우 JS's instanceof 연산자를 사용합니다.
62
62
optionalMessage:PropTypes.instanceOf(Message),
63
63
64
-
// You can ensure that your prop is limited to specific values by treating
### Requiring Single Child {#requiring-single-child}
121
+
### 하나의 자식만 요구하기 {#requiring-single-child}
123
122
124
-
With `PropTypes.element` you can specify that only a single child can be passed to a component as children.
123
+
`PropTypes.element`를 이용하여 컴포넌트의 자식들(Children)에 단 하나의 자식(Child)만이 전달될 수 있도록 명시할 수 있습니다.
125
124
126
125
```javascript
127
126
importPropTypesfrom'prop-types';
128
127
129
128
classMyComponentextendsReact.Component {
130
129
render() {
131
-
//This must be exactly one element or it will warn.
130
+
//이것은 반드시 하나의 엘리먼트여야 합니다. 아니라면, 경고(warn)가 일어날 것입니다.
132
131
constchildren=this.props.children;
133
132
return (
134
133
<div>
@@ -143,9 +142,9 @@ MyComponent.propTypes = {
143
142
};
144
143
```
145
144
146
-
### Default Prop Values {#default-prop-values}
145
+
### 초기 Prop 값 {#default-prop-values}
147
146
148
-
You can define default values for your `props` by assigning to the special `defaultProps` property:
147
+
`defaultProps` 프로퍼티를 할당함으로써 `props`의 초깃값을 정의할 수 있습니다:
149
148
150
149
```javascript
151
150
classGreetingextendsReact.Component {
@@ -156,19 +155,19 @@ class Greeting extends React.Component {
156
155
}
157
156
}
158
157
159
-
//Specifies the default values for props:
158
+
//props의 초깃값을 정의합니다.
160
159
Greeting.defaultProps= {
161
160
name:'Stranger'
162
161
};
163
162
164
-
//Renders "Hello, Stranger":
163
+
// "Hello, Stranger"를 랜더링 합니다.
165
164
ReactDOM.render(
166
165
<Greeting />,
167
166
document.getElementById('example')
168
167
);
169
168
```
170
169
171
-
If you are using a Babel transform like [transform-class-properties](https://babeljs.io/docs/plugins/transform-class-properties/) , you can also declare`defaultProps` as static property within a React component class. This syntax has not yet been finalized though and will require a compilation step to work within a browser. For more information, see the [class fields proposal](https://github.com/tc39/proposal-class-fields).
170
+
만약 당신이 [transform-class-properties](https://babeljs.io/docs/plugins/transform-class-properties/)와 같은 Babel 변환(transform)을 사용하고 있다면,`defaultProps`를 React 컴포넌트 클래스 내의 정적 프로퍼티로 선언 할 수도 있습니다. 이 문법은 아직 완성되지 않았으므로 브라우저에서 작동하기 위해서는 컴파일링 작업이 필요합니다. 더 자세한 정보를 위해서 [class fields proposal](https://github.com/tc39/proposal-class-fields)를 확인해 주시길 바랍니다.
172
171
173
172
```javascript
174
173
classGreetingextendsReact.Component {
@@ -184,4 +183,4 @@ class Greeting extends React.Component {
184
183
}
185
184
```
186
185
187
-
The `defaultProps` will be used to ensure that `this.props.name` will have a value if it was not specified by the parent component. The `propTypes` typechecking happens after `defaultProps` are resolved, so typechecking will also apply to the `defaultProps`.
186
+
`defaultProps`는 `this.props.name`의 값이 부모 컴포넌트에 의해 명시되지 않았을 때 값을 갖도록 할 것입니다. `propTypes`의 타입 확인은 `defaultProps`에도 적용되게 하기 위하여 `defaultProps`가 처리된 뒤에 일어날 것입니다.
0 commit comments