-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuote.tsx
32 lines (29 loc) · 814 Bytes
/
Quote.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React, { useState, useEffect } from "react";
import PropTypes from "prop-types";
import axios from "axios";
import {
Text,
} from 'react-native-paper';
export default function Quote(props) {
const [quote, setQuote] = useState({ text: "", attribution: "" });
const updateQuote = () => {
axios
.get(props.url + ".json", {})
.then(response => {
const data = response.data;
setQuote({ text: data.text_en, attribution: data.attribution });
})
.catch(error => {
console.log("error", error);
});
};
useEffect(() => updateQuote(), []);
return (
<Text variant='bodySmall' onPress={() => {return updateQuote() }} className="quotes">
{quote.text} ({quote.attribution})
</Text>
);
}
Quote.propTypes = {
url: PropTypes.string
};