Last active
May 14, 2019 06:06
-
-
Save faustoct1/a79bdfc973c5bac74c354b6849886d0f to your computer and use it in GitHub Desktop.
proxy interface to react-native-navigation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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