vobyjs / voby

A high-performance framework with fine-grained observable/signal-based reactivity for building rich applications.
https://voby.dev
MIT License
891 stars 22 forks source link

JSX ref #1

Closed andreichuk closed 2 years ago

andreichuk commented 2 years ago

Is JSX's 'ref' attribute supported? In the following example it does nothing:


// voby 0.16

const App = () => {
    let eInput;

    function onClick() {
        console.log("eInput: " + eInput); // outputs 'eInput: undefined'
    }

    return (
        <input type="text" ref={eInput} onClick={onClick}/>
    )
};

render(<App />, document.body);
fabiospampinato commented 2 years ago

It is supported, but it must be a function, which will be called with the node. So basically I'd recommend making that an observable.

The code you posted can't possibly work, you are just passing ref={undefined} effectively, there's no way that variable could get assigned. It works in Solid only because its transform changes how the language works, you are not really writing plain JS anymore.