LoginSignup
0
0

More than 5 years have passed since last update.

react native のライフサイクルにログを入れてみる

Posted at

前回投稿にとりあえずログをいれる。

storeが更新された場合

ストア更新(profile/updateUid)

Aスクリーン

Bスクリーン

ストア更新(profile/updateUid)

Aスクリーン

setStateした場合

❯ git diff
diff --git a/app/containers/Bscreen.js b/app/containers/Bscreen.js
index 477e965..c844821 100644
--- a/app/containers/Bscreen.js
+++ b/app/containers/Bscreen.js
@@ -50,7 +50,7 @@ class BScreen extends Component {
         <Text>{this.state.userName}</Text>
         <Button
           onPress={() => {
-            this.props.updateUid('JIRO');
+            this.setState({ userName: 'JIRO' });
           }}
           title="UPDATE name"
         />

もちろん、getDerivedStateFromPropsが呼ばれないだけ。

ストア更新(profile/updateUid)

Aスクリーン

Bスクリーン

setState

Aスクリーン

ソースコード

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0