Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

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 />)
})

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

Successfully merging this pull request may close these issues.

1 participant