Skip to content

Commit 0f7cac4

Browse files
authored
Revert "Remove setProps and replaceProps completely" (reactjs#7039)
1 parent 23f3548 commit 0f7cac4

File tree

4 files changed

+149
-0
lines changed

4 files changed

+149
-0
lines changed

docs/ref-02-component-api.it-IT.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,40 @@ boolean isMounted()
9292
> Nota:
9393
>
9494
> Questo metodo non è disponibile il componenti `class` ES6 che estendono `React.Component`. Potrebbe essere eliminato del tutto in una versione futura di React.
95+
96+
97+
### setProps
98+
99+
```javascript
100+
void setProps(
101+
object nextProps,
102+
[function callback]
103+
)
104+
```
105+
106+
Quando stai integrando con un'applicazione JavaScript esterna puoi voler segnalare un cambiamento a un componente React il cui rendering è stato effettuato con `ReactDOM.render()`.
107+
108+
Chiamare `setProps()` su un componente al livello radice cambierà le sue proprietà e scatenerà un ri-rendering. Inoltre, puoi fornire una funzione callback opzionale che verrà eseguita quando `setProps` ha terminato e il rendering del componente è terminato.
109+
110+
> Nota:
111+
>
112+
> Quando possibile, l'approccio dichiarativo di invocare nuovamente `ReactDOM.render()` sullo stesso nodo è preferibile. Quest'ultimo tende a rendere gli aggiornamenti più comprensibili. (Non vi è una differenza significativa di prestazioni tra i due approcci.)
113+
>
114+
> Questo metodo può essere chiamato soltanto su un componente al livello radice. Ovvero, è disponibile soltanto sul componente passato direttamente a `ReactDOM.render()` e nessuno dei suoi figli. Se il tuo intento è usare `setProps()` su un componente figlio, approfitta degli aggiornamenti reattivi e passa la nuova proprietà al componente figlio quando viene creato in `render()`.
115+
>
116+
> Questo metodo non è disponibile il componenti `class` ES6 che estendono `React.Component`. Potrebbe essere eliminato del tutto in una versione futura di React.
117+
118+
### replaceProps
119+
120+
```javascript
121+
void replaceProps(
122+
object nextProps,
123+
[function callback]
124+
)
125+
```
126+
127+
Come `setProps()` ma elimina ogni proprietà preesistente anziché riunire i due oggetti.
128+
129+
> Nota:
130+
>
131+
> Questo metodo non è disponibile il componenti `class` ES6 che estendono `React.Component`. Potrebbe essere eliminato del tutto in una versione futura di React.

docs/ref-02-component-api.ko-KR.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,41 @@ boolean isMounted()
9393
> 주의:
9494
>
9595
> 이 메소드는 `React.Component`를 확장한 ES6 `class` 컴포넌트에서는 사용할 수 없습니다. React의 미래 버전에서 이는 완전히 사라지게 될 것입니다.
96+
97+
98+
### setProps
99+
100+
```javascript
101+
void setProps(
102+
object nextProps,
103+
[function callback]
104+
)
105+
```
106+
107+
외부 JavaScript 애플리케이션과 연동하는 경우 `ReactDOM.render()`로 렌더링된 React 컴포넌트에 변경을 알리고 싶을 때가 있습니다.
108+
109+
최상위 컴포넌트에서 `setProps()`를 호출하면 프로퍼티를 변경하고 렌더를 다시 발생합니다. 거기에 콜백 함수를 넘기면 `setProps`가 완료되고 컴포넌트가 다시 렌더링된 다음에 한번 호출됩니다.
110+
111+
> 주의:
112+
>
113+
> 가능하다면 이것 대신 `ReactDOM.render()`를 같은 노드에서 다시 호출하는 선언적인 방법이 더 바람직합니다. 그렇게 하는 편이 업데이트에 대해 생각하는 것을 쉽게 만듭니다. (두가지 방식에 눈에 띄는 성능 차이는 없습니다.)
114+
>
115+
> 이 메소드는 최상위 컴포넌트에만 호출 가능합니다. 다시 말해, `ReactDOM.render()`에 바로 넘긴 컴포넌트에서만 사용할 수 있고 자식에서는 불가능합니다. 자식 컴포넌트에 `setProps()`를 사용하고 싶다면, 그 대신 반응적인 업데이트의 장점을 활용하여 `render()` 안에서 자식 컴포넌트를 만들 때 새로운 prop을 넘기세요.
116+
>
117+
> 이 메소드는 `React.Component`를 확장한 ES6 `class` 컴포넌트에서는 사용할 수 없습니다. React의 미래 버전에서 이는 완전히 사라지게 될 것입니다.
118+
119+
120+
### replaceProps
121+
122+
```javascript
123+
void replaceProps(
124+
object nextProps,
125+
function callback]
126+
)
127+
```
128+
129+
`setProps()`와 비슷하지만 두 객체를 합치는 대신 이전에 존재하던 props를 삭제합니다.
130+
131+
> 주의:
132+
>
133+
> 이 메소드는 `React.Component`를 확장한 ES6 `class` 컴포넌트에서는 사용할 수 없습니다. React의 미래 버전에서 이는 완전히 사라지게 될 것입니다.

docs/ref-02-component-api.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,40 @@ boolean isMounted()
9292
> Note:
9393
>
9494
> This method is not available on ES6 `class` components that extend `React.Component`. It will likely be removed entirely in a future version of React, so you might as well [start migrating away from isMounted() now](/react/blog/2015/12/16/ismounted-antipattern.html).
95+
96+
97+
### setProps
98+
99+
```javascript
100+
void setProps(
101+
object nextProps,
102+
[function callback]
103+
)
104+
```
105+
106+
When you're integrating with an external JavaScript application you may want to signal a change to a React component rendered with `ReactDOM.render()`.
107+
108+
Calling `setProps()` on a root-level component will change its properties and trigger a re-render. In addition, you can supply an optional callback function that is executed once `setProps` is completed and the component is re-rendered.
109+
110+
> Note:
111+
>
112+
> This method is deprecated and will be removed soon. This method is not available on ES6 `class` components that extend `React.Component`. Instead of calling `setProps`, try invoking ReactDOM.render() again with the new props. For additional notes, see our [blog post about using the Top Level API](/react/blog/2015/10/01/react-render-and-top-level-api.html)
113+
>
114+
> When possible, the declarative approach of calling `ReactDOM.render()` again on the same node is preferred instead. It tends to make updates easier to reason about. (There's no significant performance difference between the two approaches.)
115+
>
116+
> This method can only be called on a root-level component. That is, it's only available on the component passed directly to `ReactDOM.render()` and none of its children. If you're inclined to use `setProps()` on a child component, instead take advantage of reactive updates and pass the new prop to the child component when it's created in `render()`.
117+
118+
### replaceProps
119+
120+
```javascript
121+
void replaceProps(
122+
object nextProps,
123+
[function callback]
124+
)
125+
```
126+
127+
Like `setProps()` but deletes any pre-existing props instead of merging the two objects.
128+
129+
> Note:
130+
>
131+
> This method is deprecated and will be removed soon. This method is not available on ES6 `class` components that extend `React.Component`. Instead of calling `replaceProps`, try invoking ReactDOM.render() again with the new props. For additional notes, see our [blog post about using the Top Level API](/react/blog/2015/10/01/react-render-and-top-level-api.html)

docs/ref-02-component-api.zh-CN.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,40 @@ boolean isMounted()
9292
> 注意:
9393
>
9494
> 这个方法在从 `React.Component` 扩展的 ES6 `class` 组件里不可用。它也许会在未来的 React 版本中被完全移除,所以你也要移除它 [start migrating away from isMounted() now](/react/blog/2015/12/16/ismounted-antipattern.html)
95+
96+
97+
### setProps
98+
99+
```javascript
100+
void setProps(
101+
object nextProps,
102+
[function callback]
103+
)
104+
```
105+
106+
当和一个外部的 JavaScript 应用整合的时候,你也许会想用 `ReactDOM.render()` 给 React 组件标示一个改变。
107+
108+
在根组件上调用 `setProps()` 会改变他的属性并触发一次重绘。另外,你可以提供一个可选的回调函数,一旦 `setProps` 完成并且组件被重绘它就执行。
109+
110+
> 注意:
111+
>
112+
> 这个方法被弃用了并会很快移除.这个方法在从 `React.Component` 扩展的 ES6 `class` 组件里不可用. 取代调用 `setProps`,试着以新的 props 再次调用 `ReactDOM.render()`. 更多的注意事项,见我们的[blog post about using the Top Level API](/react/blog/2015/10/01/react-render-and-top-level-api.html)
113+
>
114+
> 如果可能,上述的在同一个节点上再次调用 `ReactDOM.render()` 的方法是优先替代的。它往往使更新更容易理解。(两种方法并没有显著的性能区别。)
115+
>
116+
> 这个方法仅能在根组件上被调用。也就是说,它仅在直接传给 `ReactDOM.render()` 的组件上可用,在它的子级上不可用。如果你倾向于在子组件上使用 `setProps()`,不要利用响应式更新,而是当子组件在 `render()` 中创建的时候传入新的 prop 到子组件中。
117+
118+
### replaceProps
119+
120+
```javascript
121+
void replaceProps(
122+
object nextProps,
123+
[function callback]
124+
)
125+
```
126+
127+
类似于 `setProps()`,但是删除任何先前存在的 props,而不是合并这两个对象。
128+
129+
> 注意:
130+
>
131+
> 这个方法被弃用了并会很快移除.这个方法在从 `React.Component` 扩展的 ES6 `class` 组件里不可用. 取代调用 `replaceProps`,试着以新的 props 再次调用 `ReactDOM.render()`. 更多的注意事项,见我们的[blog post about using the Top Level API](/react/blog/2015/10/01/react-render-and-top-level-api.html)

0 commit comments

Comments
 (0)