recompose icon indicating copy to clipboard operation
recompose copied to clipboard

Remove usage of `createFactory`

Open amannn opened this issue 5 years ago • 4 comments
trafficstars

In [email protected] this library triggers a warning:

Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

It looks like this repository uses this API in quite a few places, so perhaps this should be refactored?

amannn avatar Jun 22 '20 15:06 amannn

Was looking to see how hard this would be an it does look a bit daunting! createFactory returns a function that creates an element and createElement returns an element. Looks like the library is using createFactory to defer the mapping of props.

I wonder if it would make sense to bring the createFactory logic into this library and have it use createElement, that means the warning would go away, but if createFactory is relying on internals..... (which it isn't)

createFactory

/**
 * Return a function that produces ReactElements of a given type.
 * See https://reactjs.org/docs/react-api.html#createfactory
 */
export function createFactory(type) {
  const factory = 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.
  // Legacy hook: remove it
  factory.type = type;
  return factory;
}

Not really sure WHY they are dropping support for createFactory if createElement is going to continue to exist....

boatcoder avatar Jun 22 '20 19:06 boatcoder

Is this fixed?

bigtone1284 avatar Mar 17 '21 07:03 bigtone1284

Since this method (createFactory) has been deprecated in React 16.x, is it possible that this project will stop working when/if a future release of React drops support for it?

customcommander avatar Mar 29 '21 12:03 customcommander

Now that our projects have moved to React 17 we are now also seeing this warning from another npm package we use that itself uses recompose. Our assumption is that in React 18 it will become breaking.

dominicfraser avatar Aug 20 '21 08:08 dominicfraser