Last active
January 16, 2017 17:25
-
-
Save fogonthedowns/d69ca619180b0e03cf86d7ed608d070f to your computer and use it in GitHub Desktop.
node-craigslist node module
This file contains 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, { Component } from 'react'; | |
import { AppRegistry, Text, TextInput, View, TouchableHighlight } from 'react-native'; | |
import craigslist from 'node-craigslist' | |
// The following line, substituted for the import statement above produces the same result: | |
// var craigslist = require('node-craigslist') | |
var client = new craigslist.Client({ | |
city : 'seattle' | |
}); | |
client | |
.list() | |
.then((listings) => { | |
// play with listings here... | |
listings.forEach((listing) => console.log(listing)); | |
}) | |
.catch((err) => { | |
console.error(err); | |
}); | |
class MyButton extends Component { | |
_onPressButton() { | |
console.log("You tapped the button!"); | |
} | |
render() { | |
return ( | |
<TouchableHighlight onPress={this._onPressButton}> | |
<Text>Button</Text> | |
</TouchableHighlight> | |
); | |
} | |
} | |
class PizzaTranslator extends Component { | |
constructor(props) { | |
super(props); | |
this.state = {text: ''}; | |
} | |
render() { | |
return ( | |
<View style={{padding: 10}}> | |
<TextInput | |
style={{height: 40}} | |
placeholder="Type here to translate!" | |
onChangeText={(text) => this.setState({text})} | |
/> | |
<Text style={{padding: 10, fontSize: 42}}> | |
{this.state.text.split(' ').map((word) => word && '🍕').join(' ')} | |
</Text> | |
<MyButton /> | |
</View> | |
); | |
} | |
} | |
AppRegistry.registerComponent('AwesomeProject', () => PizzaTranslator); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment