Last active
August 3, 2020 01:27
-
-
Save YounglanHong/ccc296dba0e5534cff3c6c7a88f2fea4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // local state | |
| let [results, setResults] = useState(""); | |
| // useEffect: mount, update -- 😈Infinite Loop | |
| useEffect(() => { | |
| axios | |
| .get(`${API_URL}movie/${props.id}?api_key=${API_KEY}`) | |
| .then((res) => { | |
| console.log(res.data); | |
| // 영화 id로 요청한 결과 로컬 state로 관리 | |
| setResults(res.data); | |
| }) | |
| .catch((err) => { | |
| console.log(err); | |
| }); | |
| }); | |
| // useEffect: mount | |
| useEffect(() => { | |
| axios | |
| .get(`${API_URL}movie/${props.id}?api_key=${API_KEY}`) | |
| .then((res) => { | |
| console.log(res.data); | |
| // 영화 id로 요청한 결과 로컬 state로 관리 | |
| setResults(res.data); | |
| }) | |
| .catch((err) => { | |
| console.log(err); | |
| }); | |
| }, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment