Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 = 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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement