HydrationStrategy: ((hydrate: (() => void), forEachElement: ((cb: ((el: Element) => any)) => void)) => (() => void) | void)

A lazy hydration strategy for async components.

Type declaration

    • (hydrate, forEachElement): (() => void) | void
    • Parameters

      • hydrate: (() => void)

        call this to perform the actual hydration.

          • (): void
          • Returns void

      • forEachElement: ((cb: ((el: Element) => any)) => void)

        iterate through the root elements of the component's non-hydrated DOM, accounting for possible fragments.

          • (cb): void
          • Parameters

            • cb: ((el: Element) => any)
                • (el): any
                • Parameters

                  • el: Element

                  Returns any

            Returns void

      Returns (() => void) | void

      a teardown function to be called if the async component is unmounted before it is hydrated. This can be used to e.g. remove DOM event listeners.