Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.

Partial support for story with render function #38

Merged
merged 2 commits into from May 22, 2018

Conversation

pocka
Copy link
Owner

@pocka pocka commented May 22, 2018

Summary

Add partial support for story that have render function instead of template.
Since Vue.js is not supported custom renderer for now, this changes do hacks: call render function manually with custom createElement callback which returns JSX string.

See: #36

Limitations

  • Accessing this in render throws an exception.

    withInfo('summary', (() => ({
      data() {
        return { name: 'pocka' }
      },
      render(h) {
        return h('p', [`Hello, ${this.name}`]) // Error
      }
    })))
  • All variables will be evaluated.

    const foo = 3
    return <p>{foo}</p>

    will be

    return <p>{3}</p>
  • Functions will be inlined.

    const myFunc = ev => console.log(ev)
    return <div onClick={myFunc}>foo</div>

    will be

    ;<div onClick={function (ev) {console.log(ev);}}>foo</div>

pocka added 2 commits May 22, 2018 14:47
* Partial support
* Using this inside render throws exception
@pocka pocka added this to the v0.4.2 milestone May 22, 2018
@pocka pocka self-assigned this May 22, 2018
@pocka pocka merged commit e4614b7 into master May 22, 2018
@pocka pocka deleted the feature/render-function branch May 22, 2018 06:36
@pocka pocka mentioned this pull request May 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant