diff --git a/lib/core/src/react/component-from-react.ts b/lib/core/src/react/component-from-react.ts index 5745481d23..a47c90188d 100644 --- a/lib/core/src/react/component-from-react.ts +++ b/lib/core/src/react/component-from-react.ts @@ -2,9 +2,9 @@ import {createRef, render, h} from 'preact'; import {Component as ComponentBase} from '../component'; import {mergeProps} from '../helpers'; -import type {ComponentEventsDefnition} from '../component'; import type {Component as ComponentReact, ComponentClass} from 'preact'; -import {I18nLangMap} from '../i18n'; +import {type I18nLangMap} from '../i18n'; +import type {ComponentEventsDefnition} from '../component'; export class ComponentFromReact = ComponentReact, E extends ComponentEventsDefnition = {}, U extends HTMLElement = HTMLElement> extends ComponentBase { /** @@ -71,7 +71,7 @@ export class ComponentFromReact = * @param options new options. */ render(options?: Partial, reset?: boolean) { - const {element} = this; + const {element, $: instance} = this; const {Component, replace} = this.constructor; const {$replace = replace, $optionsFromDataset, ...userOptions} = this.setOptions(options, reset); const props = { @@ -79,8 +79,9 @@ export class ComponentFromReact = ...userOptions, }; if (reset) { - (this.$ as {resetState?: (props?: Record, init?: boolean) => void})?.resetState?.(userOptions); + (instance as {resetState?: (props?: Record, init?: boolean) => void})?.resetState?.(userOptions); } + if ($replace && (Component as {HElement?: boolean}).HElement && (element.tagName.toLowerCase() === $replace || $replace === true)) { const attrs = Array.from(element.attributes).reduce>((data, attribute) => { const {name, value} = attribute;