Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Remove usage of createFactory #806

Open
amannn opened this issue Jun 22, 2020 · 4 comments · May be fixed by #826
Open

Remove usage of createFactory #806

amannn opened this issue Jun 22, 2020 · 4 comments · May be fixed by #826

Comments

@amannn
Copy link

amannn commented Jun 22, 2020

In react@16.13.1 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?

@boatcoder
Copy link

boatcoder commented Jun 22, 2020

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....

jtarasova referenced this issue in Opexflow/opexflow Sep 15, 2020
brodybits added a commit to brodysoft/recompose that referenced this issue Feb 3, 2021
to avoid using the deprecated React.createFactory function

(and update .size-snapshot.json)

resolves acdlite#806
@brodybits brodybits linked a pull request Feb 3, 2021 that will close this issue
5 tasks
@bigtone1284
Copy link

Is this fixed?

@customcommander
Copy link

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?

@dominicfraser
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants