Last active
August 27, 2018 13:22
-
-
Save mxmzb/c266c48e9ec16c7c44d8f020a0c58f08 to your computer and use it in GitHub Desktop.
rn screen file
This file contains hidden or 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, { Fragment } from "react"; | |
import { SafeAreaView } from "react-native"; | |
import { Query } from "react-apollo"; | |
import { scheduleQuery } from "src/modules/Schedule/graphql/queries"; | |
import { Header, HeaderConfig } from "src/modules/shared/components"; | |
import { ScheduleFull } from "src/modules/Schedule/components"; | |
export default class ScheduleScreen extends React.PureComponent { | |
static navigationOptions = ({ navigation }) => { | |
return { | |
// foo.title here should be `null` while loading and "bar" after data loaded | |
// Receiver might be moved into the Header component as well, shouldn't really matter | |
header: () => <Receiver>{foo => (<Header showBack navigation={navigation} title={foo.title} />)}</Receiver>, | |
}; | |
}; | |
render() { | |
const { navigation } = this.props; | |
return ( | |
<SafeAreaView> | |
<Query query={scheduleQuery} variables={{ id: navigation.getParam("scheduleId") }}> | |
{({ data, loading }) => { | |
if (loading) return null; | |
return ( | |
<Fragment> | |
<HeaderConfig title={"bar"} /> | |
<ScheduleFull schedule={data.schedule} navigation={navigation} /> | |
</Fragment> | |
); | |
}} | |
</Query> | |
</SafeAreaView> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment