reactionic icon indicating copy to clipboard operation
reactionic copied to clipboard

ES6 context not available

Open ptfly opened this issue 8 years ago • 1 comments

First, awesome project guys!

I'm trying to use IonModal for example, and in my component, I'm setting:

static contextTypes = {
    router:React.PropTypes.object,
    ionShowModal: React.PropTypes.func,
    ionKeyboardHeight: React.PropTypes.number,
    ionPlatform: React.PropTypes.object
};

But when I ran the app (in browser or in cordova/ ios simulator) all context types are undefined except the router. Any idea how can I fix this?

Object { router: Object, ionShowModal: undefined, ionKeyboardHeight: undefined, ionPlatform: undefined }

I'm using latest official react release, thanks!

ptfly avatar Oct 11 '16 07:10 ptfly

I'm able to use the static contextTypes syntax, but I've noticed that some of the ion props are not defined immediately. But here is an example of using the ionPlatform context that I have used:

class Example extends Component {
  static contextTypes = {
    ionPlatform: object,
  }
  
  render() {
    return (<i className={this.context.ionPlatform.isIos ? 'ion-ios-arrow-back' : 'ion-android-arrow-back'} />);
  }
}

idmontie avatar Dec 24 '16 22:12 idmontie