React で Hooks を使っているとします。 画面を表示した時に、外部APIから取得した情報を表示したい場合には、どうすればよいでしょうか?
React Hooks で画面を表示したときに一度だけ処理を行いたいときには useEffect を使います。 外部APIにリクエストをするのに、今回は axios を使います。
@bpteague Has an excellent update solution as of February 2025 using modern tools and an updated workflow.
This gist will remain here, but is deprecated. I'll keep it here historical and link-preservation purposes only. I strongly encourage everyone to check out the solution above!
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks. | |
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/) | |
(() => { | |
const SHOW_SIDES = false; // color sides of DOM nodes? | |
const COLOR_SURFACE = true; // color tops of DOM nodes? | |
const COLOR_RANDOM = false; // randomise color? | |
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com) | |
const MAX_ROTATION = 180; // set to 360 to rotate all the way round | |
const THICKNESS = 20; // thickness of layers | |
const DISTANCE = 10000; // ¯\\_(ツ)_/¯ |