LoginSignup
0
1

More than 5 years have passed since last update.

React Native 動的にUIを更新

Last updated at Posted at 2019-04-05

React Native 動的にUIを更新

OverView

変数や状態によってUIを表示にしたり、非表示にしたり、したい場合があるかと思います。
その場合下記のように実装することにより実現できます。

<View style={layout(val)} />

function layout(val) {
    if (val === "no") {
        return {
        backgroundColor: #fff,
      };
    }
    return {
        backgroundColor: #000,
    };
}

動作確認を行なっていないので動作するかわかりませんが、概念的にはこんな感じです。

0
1
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
1