Skip to content

Commit

Permalink
Update native-modules-ios
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnylqm committed Nov 5, 2020
1 parent 6739a53 commit 504c921
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cndocs/intro-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ export default function CatApp() {

## State 状态

While you can think of props as arguments you use to configure how components render, **state**就像是组件的私人数据记录。 Sate is useful for handling data that changes over time or that comes from user interaction. State gives your components memory!
While you can think of props as arguments you use to configure how components render, **state**就像是组件的私人数据记录。状态用于记录那些随时间或者用户交互而变化的数据。Sate is useful for handling data that changes over time or that comes from user interaction. State gives your components memory!

> As a general rule, use props to configure a component when it renders. Use state to keep track of any component data that you expect to change over time. The following example takes place in a cat cafe where two hungry cats are waiting to be fed. Their hunger, which we expect to change over time (unlike their names), is stored as state. To feed the cats, press their buttons—which will update their state.
> 按惯例来说,props用来配置组件的第一次渲染(初始状态)。Use state to keep track of any component data that you expect to change over time. The following example takes place in a cat cafe where two hungry cats are waiting to be fed. Their hunger, which we expect to change over time (unlike their names), is stored as state. To feed the cats, press their buttons—which will update their state.
<div class="toggler">
<ul role="tablist" class="toggle-syntax">
Expand Down Expand Up @@ -463,7 +463,7 @@ And you set individual values inside the state object by passing an object with
</Button>
```

> Do not change your component's state directly by assigning it a new value with `this.state.hunger = false`. Calling `this.setState()` allows React to track changes made to state that trigger rerendering. Setting state directly can break your app's reactivity! When `this.state.isHungry` is false, the `Button`’s `disabled` prop is set to `false` and its `title` also changes:
> 不要直接给组件state赋值(比如`this.state.hunger = false`)来修改状态。Calling `this.setState()` allows React to track changes made to state that trigger rerendering. Setting state directly can break your app's reactivity! When `this.state.isHungry` is false, the `Button`’s `disabled` prop is set to `false` and its `title` also changes:
```jsx
<Button
Expand Down
2 changes: 1 addition & 1 deletion cndocs/native-modules-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ RCT_EXPORT_METHOD(doSomethingExpensive:(NSString *)param callback:(RCTResponseSe
## 依赖注入
bridge 会自动注册实现了`RCTBridgeModule`协议的模块,但是你可能也希望能够初始化自定义的模块实例(这样可以注入依赖)。
bridge 会自动注册实现了`RCTBridgeModule`协议的模块,但是你可能也希望能够自己去初始化自定义的模块实例(这样可以注入依赖)。
要实现这个功能,你需要实现`RCTBridgeDelegate`协议,初始化`RCTBridge`,并且在初始化方法里指定代理。然后用初始化好的`RCTBridge`实例初始化一个`RCTRootView`。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ RCT_EXPORT_METHOD(doSomethingExpensive:(NSString *)param callback:(RCTResponseSe
## 依赖注入
bridge 会自动注册实现了`RCTBridgeModule`协议的模块,但是你可能也希望能够初始化自定义的模块实例(这样可以注入依赖)。
bridge 会自动注册实现了`RCTBridgeModule`协议的模块,但是你可能也希望能够自己去初始化自定义的模块实例(这样可以注入依赖)。
要实现这个功能,你需要实现`RCTBridgeDelegate`协议,初始化`RCTBridge`,并且在初始化方法里指定代理。然后用初始化好的`RCTBridge`实例初始化一个`RCTRootView`。
Expand Down

0 comments on commit 504c921

Please sign in to comment.