Created
March 30, 2021 07:26
-
-
Save evasconcelos/f0b47a5e4a9f619379806172627fd166 to your computer and use it in GitHub Desktop.
Dependency inversion principle: Breaking it
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 { useEffect, useState } from "react"; | |
import axios from "axios"; | |
export default function App() { | |
const [fact, setFact] = useState(""); | |
useEffect(() => { | |
axios.get("https://cat-fact-herokuapp.com/facts").then((res) => { | |
setFact(res.data[0].text); | |
}); | |
}, []); | |
return ( | |
<div className="App"> | |
<h1>Cat Facts</h1> | |
<p>{fact}</p> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment