Skip to content

feat(babel-sugar-inject-h): add support for functional jsx h injections #170

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

allex
Copy link
Contributor

@allex allex commented Nov 17, 2020

Add support for purge functional jsx construct with h be auto injected. eg.

const compGenerator = (funcRender, customize) => { /* factory for variant components generator */ }

const Foo = compGenerator((ctx) => (
  <C { ...ctx } scopedSlots={{
    foo: ({ value }) => (<Item value={ value } />)
  }} />
), {})

=>

var compGenerator = function (funcRender, customize) { /* factory for variant components generator */ };

var Foo = compGenerator(function (h, ctx) {
  return h("C", _mergeJSXProps([{}, ctx, {
    "scopedSlots": {
      foo: function foo(_ref) {
        var value = _ref.value;
        return h("Item", {
          "attrs": {
            "value": value
          }
        });
      }
    }
  }]));
}, {});

Also support any purge functional render-like code snippet:

new Vue({
  ...
  foo: function () { return <C /> }
  render: () => <App />
})

=>

new Vue({
 ...
  foo: function (h) { return h(<C />) }
  render: (h) => h(<App />)
})

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant