For example I have a simple directive like this:
export const inputLogger = (el: HTMLInputElement) => {
const onInput = (e: Event) => {
console.log((e.currentTarget as HTMLInputElement).value)
}
el.addEventListener("input", onInput);
};
and my component looks like this
const CustomInput: Component<JSX.InputHTMLAttributes<HTMLInputElement>> = (props) => {
return <input {...props} />
}
function Counter() {
return (
<>
<CustomInput use:inputLogger /> {/* directive is not being used */}
<br />
<input use:inputLogger /> {/* directive works properly */}
</>
);
}
Seems like inputLogger
directive doesn't work properly when being passed as a prop to other component, but works fine when passed to a native input element.
Am I doing something wrong? Is there a workaround for this or is this a limitation from Solid.js?