Skip to content

Instantly share code, notes, and snippets.

@avencat
Last active April 27, 2017 09:15
Show Gist options
  • Select an option

  • Save avencat/d96742b8ad4f94631e059960eb350209 to your computer and use it in GitHub Desktop.

Select an option

Save avencat/d96742b8ad4f94631e059960eb350209 to your computer and use it in GitHub Desktop.
Test Nachos UI, when you press enter on the first field, it should focus the password field but it doesn't, instead, an error is shown.
import React, {
Component
} from 'react';
import {
StyleSheet,
View,
} from 'react-native';
import {
Button,
Input,
H1,
} from 'nachos-ui';
export default class TestNachosUI extends Component {
constructor(props) {
super(props);
this.on = this.on.bind(this);
}
on(event: string, ref: string) {
this.refs[ref][event]();
}
render() {
return (
<View style={styles.view}>
<H1>Login</H1>
<Input onSubmitEditing={() => {
this.on("focus", "password");
}}
placeholder='Email'
style={[styles.input]}
/>
<Input ref='password' placeholder='Password' style={[styles.input]} />
<Button>Login</Button>
</View>
);
}
};
const styles = StyleSheet.create({
view: {
alignItems: 'center',
flex: 1,
justifyContent: 'center',
paddingTop: 15,
},
input: {
margin: 15,
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment