Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { AppRegistry, Text, TextInput, View, TouchableHighlight } from 'react-native';
  3. import craigslist from 'node-craigslist'
  4.  
  5. // The following line, substituted for the import statement above produces the same result:
  6. // var craigslist = var craigslist = require('node-craigslist')
  7.  
  8. var client = new craigslist.Client({
  9. city : 'seattle'
  10. });
  11.  
  12. client
  13. .list()
  14. .then((listings) => {
  15. // play with listings here...
  16. listings.forEach((listing) => console.log(listing));
  17. })
  18. .catch((err) => {
  19. console.error(err);
  20. });
  21.  
  22.  
  23. class MyButton extends Component {
  24. _onPressButton() {
  25. console.log("You tapped the button!");
  26. }
  27.  
  28. render() {
  29. return (
  30. <TouchableHighlight onPress={this._onPressButton}>
  31. <Text>Button</Text>
  32. </TouchableHighlight>
  33. );
  34. }
  35. }
  36.  
  37. class PizzaTranslator extends Component {
  38. constructor(props) {
  39. super(props);
  40. this.state = {text: ''};
  41. }
  42.  
  43. render() {
  44. return (
  45. <View style={{padding: 10}}>
  46. <TextInput
  47. style={{height: 40}}
  48. placeholder="Type here to translate!"
  49. onChangeText={(text) => this.setState({text})}
  50. />
  51. <Text style={{padding: 10, fontSize: 42}}>
  52. {this.state.text.split(' ').map((word) => word && '🍕').join(' ')}
  53. </Text>
  54. <MyButton />
  55. </View>
  56. );
  57. }
  58. }
  59.  
  60. AppRegistry.registerComponent('AwesomeProject', () => PizzaTranslator);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement