LoginSignup
6
1

More than 5 years have passed since last update.

ReactNativeでpropTypesにstyleオブジェクトを指定する方法

Last updated at Posted at 2017-06-22

ReactNative v44以降ではViewPropTypes.styleを使う

import {ViewPropTypes} from 'react-native'

export default class MyClass extends Component {
  static propTypes = {
    style: ViewPropTypes.style
  }
}

これまでは View.propTypes.style が使えたがDeprecatedになった。
使うと下記の警告が表示される。

Warning: View.propTypes has been deprecated and will be removed in a future version of ReactNative. Use ViewPropTypes instead.

関連リファレンス

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