Vendicto
02/28/2018, 3:34 PMhuv1k
02/28/2018, 3:36 PMhuv1k
02/28/2018, 3:39 PMVendicto
02/28/2018, 3:42 PMVendicto
02/28/2018, 3:43 PMiamclaytonray
02/28/2018, 3:43 PMrender(). IE:
export class Example extends React.Component {
example() {
// mutation
}
render() {
return (
<View>
<Button onPress={() => this.example.bind(this)}>
<Text></Text>
</Button>
</View>
);
}
}Vendicto
02/28/2018, 3:44 PMiamclaytonray
02/28/2018, 3:46 PMiamclaytonray
02/28/2018, 3:46 PMiamclaytonray
02/28/2018, 3:47 PMcompose but have to change graphql() a bit, to add in propsVendicto
02/28/2018, 3:52 PMconst checkUsername = graphql(CHECK_EXIST_USERNAME, { name: 'checkUsername',
options: (ownProps) => ({
variables: {
username: "params from state here (input some value)"
}
})
});
const signupUser = graphql(SIGNUP_USER_MUTATION, { name: 'signUpUserMutation' });
const SignUpScreen = compose(
signupUser,
checkUsername
);Vendicto
02/28/2018, 3:52 PMVendicto
02/28/2018, 4:03 PMquery {
allUsers(filter: {username: "testUsername"}) {
id
fullName
username
email
age
}
}Vendicto
02/28/2018, 4:04 PMiamclaytonray
02/28/2018, 4:33 PMexport const SignUpScreen = graphql(CHECK_EXIST_USERNAME, {
options: (props) => ({
variables: {
username: props.username,
}
})
})(SignUpScreenContainer); // name of class componentsiamclaytonray
02/28/2018, 4:34 PMexport class Example extends React.Component {
render() {
const { username } = this.props.navigation.state.params;
return (
<View>
<SignUpScreen
username={username}
// etc
/>
</View>
);
}
}iamclaytonray
02/28/2018, 4:38 PMvariables in the graphql HOC don’t take in the full prop. You add the navigation.state.params... etc to that component (SignUpScreen) and that’s how props are read from the HOCVendicto
02/28/2018, 4:43 PMVendicto
02/28/2018, 4:45 PMiamclaytonray
02/28/2018, 4:50 PMif (username) {
return; // return the user or do some other type of logic
} else {
console.log('Error');
return; // return some component with an error or something to that degree
}iamclaytonray
02/28/2018, 4:51 PM