From d3cef408bb438c426d690315fc28fc2840c9c7dc Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 2 Aug 2017 19:14:14 +0100 Subject: [PATCH] Use createElement rather than createFactory in react-dom-factories This is a tiny bit more future-proof. --- packages/react-dom-factories/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/react-dom-factories/index.js b/packages/react-dom-factories/index.js index ceca5fb48c..3c28f9da27 100644 --- a/packages/react-dom-factories/index.js +++ b/packages/react-dom-factories/index.js @@ -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. `.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.