是否可以在 React Native 中使用 defaultProps?我尝试了以下 2 种定义 defaultProps 的方法,但在尝试访问 defaultProp 时得到 null
export default class Foo extends Component {
  // 1. define defaultProps within Class
  static defaultProps = {
    someData: 'Hello',
  }
  constructor(props) {
    super(props);
  }
  componentDidMount() {
    console.log(this.props.someData);
  }
  render() {
    return (
      <View> {this.props.someData} </View>
    )
  }
}
  // 2. define defaultProps outside Class
Foo.defaultProps = { someData: 'Hello' }