developit / htm

Hyperscript Tagged Markup: JSX alternative using standard tagged templates, with compiler support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(Question) rebinding createElement on the fly

rmorshea opened this issue · comments

I have a case where I want users of an application extension I'm developing to be able to specify what React they are using. So for example, instead of simply doing:

const html = htm.bind(React.createElement)

I would actually need to do:

let html;

function bindElementConstructor(createElement) {
    html = htm.bind(createElement);
}

// set a default constructor
bindElementConstructor(React.createElement);

// make this rebinding function available to users
export bindElementConstructor

function SomeComponent() {
    // no use the rebindable 'html' reference in a component
    return html`<div />`

Is such a thing possible?

Never mind, this doesn't actually solve my problem.