Skip to content

passthrough ref callback causes (Cannot set property which has only a getter) #77

Description

@tmm1

a component approximately like:

exportconstInlineTextArea=(props: {setRef?: (ref: HTMLInputElement)=>void;})=>{return(<inputref={props.setRef}

is normally translated to:

exportconstInlineTextArea=(props: {setRef?: (ref: HTMLInputElement)=>void;})=>{return(()=>{const_el$=_tmpl$();const_ref$=props.setRef;typeof_ref$==="function" ? _$use(_ref$,_el$) : props.setRef=_el$;

but with solid-refresh:

const_REGISTRY=_$$registry();constInlineTextArea_1=_$$component(_REGISTRY,"InlineTextArea_1",_props=>/*@refresh jsx-skip*/(()=>{var_el$=_tmpl$();var_ref$=_props.v0;typeof_ref$==="function" ? _$use(_ref$,_el$) : _props.v0=_el$;
...
exportconstInlineTextArea=_$$component(_REGISTRY,"InlineTextArea",(props: {setRef?: (ref: HTMLInputElement)=>void;})=>{return/*@refresh jsx-skip*/_$createComponent(InlineTextArea_1,{getv0(){returnprops.setRef;},

the _props.v0 = breaks:

TypeError: Cannot set property v0 of #<Object> which has only a getter
at _$$component.location at solid-refresh.mjs

my workaround is:

 <input
- ref={props.setRef}+ ref={props.setRef ?? (() => {})}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions