Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfranklin committed Dec 11, 2024
1 parent a095b50 commit d2a2478
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
32 changes: 17 additions & 15 deletions minified-with-source-maps/app.js
Original file line number Diff line number Diff line change
@@ -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 }, '')]);
}
10 changes: 5 additions & 5 deletions minified-with-source-maps/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
});
}

0 comments on commit d2a2478

Please sign in to comment.