Use createElement rather than createFactory in react-dom-factories

This is a tiny bit more future-proof.
This commit is contained in:
Dan Abramov
2017-08-02 19:14:17 +01:00
parent c0492cb555
commit d3cef408bb
+9 -1
View File
@@ -37,7 +37,15 @@
/**
* Create a factory that creates HTML tag elements.
*/
var createDOMFactory = React.createFactory;
function createDOMFactory(type) {
var factory = React.createElement.bind(null, type);
// Expose the type on the factory and the prototype so that it can be
// easily accessed on elements. E.g. `<Foo />.type === Foo`.
// This should not be named `constructor` since this may not be the function
// that created the element, and it may not even be a constructor.
factory.type = type;
return factory;
};
/**
* Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.