Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import axios from 'axios';
- import { View, Text, TextInput } from 'react-native';
- import EventEmitter from 'event-emitter';
- const api =
- 'https://api.github.com/repos/yilung7817/react-native-test/issues?access_token=b754068dd7931c3fa2855763fa0e620359ef32a5';
- import { Dispatcher } from 'flux';
- class AppDispatcher extends Dispatcher {
- handleViewAction(action) {
- this.dispatch({
- action: action,
- });
- }
- }
- export var dispatcher = new AppDispatcher();
- export default class App extends React.Component {
- constructor(props, context) {
- super(props, context);
- this.state = {
- issues: [],
- search: '',
- };
- }
- componentDidMount() {
- // this.getApi();
- }
- getApi(api) {
- this.setState({search:api})
- setTimeout(() => {
- axios
- .get(`https://api.github.com/users/${this.state.search}`)
- .then((response) => {
- var issues = response.data;
- this.setState({
- issues: issues,
- });
- });
- }, 2000);
- }
- render() {
- return (
- <View>
- <TextInput
- value={this.state.search}
- onChangeText={(text) => this.getApi(text)}
- style={{ width: 200, height: 200, borderWidth: 1 }}
- />
- <Text>{JSON.stringify(this.state.issues)}</Text>
- </View>
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement