Skip to content

Instantly share code, notes, and snippets.

@faustoct1
Last active May 14, 2019 06:06
Show Gist options
  • Save faustoct1/a79bdfc973c5bac74c354b6849886d0f to your computer and use it in GitHub Desktop.
Save faustoct1/a79bdfc973c5bac74c354b6849886d0f to your computer and use it in GitHub Desktop.
proxy interface to react-native-navigation
import React, { Component } from 'react';
let Current=null
class Proxy extends Component {
static navigationOptions = ({ navigation, navigationOptions }) => {
const { params } = navigation.state;
return {
title: params.title,
headerStyle: { backgroundColor: '#fff' },
headerTintColor: '#000',
};
};
initAsync = async (params) => {
}
constructor(props) {
super(props)
this.initAsync(props.navigation.state.params)
this.component = props.navigation.state.params.component
this.params = props.navigation.state.params
this.state = {
loaded:false
}
}
componentDidMount = async() => {
/*
Registre seus componentes aqui :)
*/
if(this.component=='List'){
Current = require('./components/List.js').default
}
else if(this.component=='ABC'){
Current = require('./components/ABC.js').default
}
this.setState({ loaded : true })
}
render = () => {
if(!this.state.loaded) return null
return <Current {...this.params}/>
}
}
export default Proxy;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment