Skip to content

Commit

Permalink
Fix signature
Browse files Browse the repository at this point in the history
  • Loading branch information
timowestnosto committed Jan 24, 2024
1 parent 7cba02b commit 9bcda14
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/utils/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type OnClickBindings<State> = {
}) => unknown
}

export async function createDropdown<State>(
export function createDropdown<State>(
container: HTMLElement,
initialState: PromiseLike<State>,
render: (container: HTMLElement, state: State) => void | PromiseLike<void>,
Expand Down Expand Up @@ -225,15 +225,18 @@ export async function createDropdown<State>(
container.innerHTML = ""
}

const state = await Promise.resolve(initialState)
await Promise.resolve(render(container, state as State))

// Without setTimeout React does not have committed DOM changes yet, so we don't have the correct elements.
setTimeout(() => {
loadElements()
bindDataCallbacks()
hide()
}, 0)
async function init() {
const state = await Promise.resolve(initialState)
await Promise.resolve(render(container, state as State))

// Without setTimeout React does not have committed DOM changes yet, so we don't have the correct elements.
setTimeout(() => {
loadElements()
bindDataCallbacks()
hide()
}, 0)
}
init()

return {
update,
Expand Down

0 comments on commit 9bcda14

Please sign in to comment.