diff --git a/minified-with-source-maps/app.js b/minified-with-source-maps/app.js index 898d9cc..1789eda 100644 --- a/minified-with-source-maps/app.js +++ b/minified-with-source-maps/app.js @@ -1,29 +1,31 @@ -import {h, render} from 'preact' -import {useEffect, useRef, useState} from 'preact/hooks' -import {loadImage} from './load.js'; +import { h, render } from 'preact'; +import { useEffect, useRef, useState } from 'preact/hooks'; +import { loadImage } from './load.js'; const app = h(MyApp, null, ''); -render(app, document.querySelector('#app')) +render(app, document.querySelector('#app')); function MyApp(props) { - const [image, setImage] = useState(null) + const [image, setImage] = useState(null); useEffect(async () => { const image = await loadImage(); - setImage(image) - }, []) + setImage(image); + }, []); - useEffect(()=> { - if(ref && ref.current && ref.current instanceof HTMLElement && image !== null) { - ref.current.appendChild(image) + useEffect(() => { + if ( + ref && + ref.current && + ref.current instanceof HTMLElement && + image !== null + ) { + ref.current.appendChild(image); } - }, [image]) + }, [image]); const ref = useRef(); - return h('div', null, [ - h('h1', null, 'Hello world'), - h('div', {ref}, ''), - ]) + return h('div', null, [h('h1', null, 'Hello world'), h('div', { ref }, '')]); } diff --git a/minified-with-source-maps/load.js b/minified-with-source-maps/load.js index aea1139..7c047d9 100644 --- a/minified-with-source-maps/load.js +++ b/minified-with-source-maps/load.js @@ -2,9 +2,9 @@ export function loadImage() { const img = 'https://placehold.co/500x500'; const image = new Image(); image.src = img; - return new Promise(resolve => { - image.onload = function() { - resolve(image) - } - }) + return new Promise((resolve) => { + image.onload = function () { + resolve(image); + }; + }); }