Skip to content

Instantly share code, notes, and snippets.

@mxmzb
Last active August 27, 2018 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxmzb/c266c48e9ec16c7c44d8f020a0c58f08 to your computer and use it in GitHub Desktop.
Save mxmzb/c266c48e9ec16c7c44d8f020a0c58f08 to your computer and use it in GitHub Desktop.
rn screen file
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