-
Notifications
You must be signed in to change notification settings - Fork 26
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
Expose pragma option for createVNode name #43
Comments
We can add that, but I wonder what is the use case behind this? there is Inferno.options.createVNode if you want to hook into it? |
In short.
//..
const di = new DiFactory({
createVNode: infernoCreateVNode,
component: createReactRdiAdapter(Component)
})
.create()
render(
di.createVNode(16, Hello, {text: 'test'}),
window.document.getElementById('app')
) I can adopt react.createElement to createVNode without recompiling my components.
function Hello(
{text}: {
text: string;
},
{user}: {
user: User;
}
) {
const set = new BaseSetter(user).create(BaseSetter.createEventSet)
return <div>
<h1>Hello {user.name}</h1>
<input value={user.name} onInput={set.name} />
</div>
} babel-plugin-metadata extract types info from second argument, dependency injection resolves them and di.createVNode is a bridge to di, that wraps component to something this: class HelloWrapped extends Inferno.Component {
render() {
return Hello(this.props, di.state, Inferno.createVNode)
}
}
I can't use createVNode as singletone from imports. In example below component B has an User state from root container "A" has shallow copy of root di container with own separate copy of User. User in A !== User in B. For hierachical injectors feature i need to create own copy of createVNode for A. createVNode in A !== createVNode in B. It's works like hierachical dependency injectors in angular2. class User {}
function A(props: {}, state: {user: User;}, createVNode: CreateVNode) {
return <div/>
}
component({
register: [User]
})(A)
function b(props: {}, state: {user: User;}, createVNode: CreateVNode) {
return <A/>
}
const di = new DiFactory({
createVNode: infernoCreateVNode,
component: createReactRdiAdapter(Component)
})
.create()
Inferno.render(
di.createVNode(16, Hello, {text: 'test'}),
window.document.getElementById('app')
) More complex todo example, EditingTodo and TodoViewService created per each TodoView. |
I see, thanks for comment. Can you send PR to add this feature, it should be trivial task. |
Merged and released 3.1.0. Thank you @zerkalica |
In babel-plugin-transform-react-jsx i can do:
Please add same thing to your plugin.
In reactive-di i use dependency injection techiques and my components are independed from react, inferno, whatever. They are really pure, without framework bindings. Passing createVNode to components also clearly solves context inheritance problem. It's works like hierachical dependency injectors in angular2.
I use createVNode only as interface for interfactions with di container. It's format is better optimized than createElement. But i don't want to create function createVNode instead of delegating object with method.
In di core binded to this, it's not good:
I want to pass di core object instead of function, to do something like this:
The text was updated successfully, but these errors were encountered: