omcljs / om

ClojureScript interface to Facebook's React
6.66k stars 362 forks source link

Warning: A Component: React.createClass is deprecated #881

Open rinama opened 7 years ago

rinama commented 7 years ago

After upgrading om to version "1.0.0-beta1", the following error is printed in the console (in development mode only) react.inc.js:3287 Warning: A Component: React.createClass is deprecated and will be removed in version 16. Use plain JavaScript classes instead. If you're not yet ready to migrate, create-react-class is available on npm as a drop-in replacement.

danielstockton commented 7 years ago

It's coming from here. Other projects e.g. reagent solved it by depending on cljsjs/create-react-class and replacing with a call to js/createReactClass.

bhauman commented 6 years ago

I would advise working on a solution that extends React.Component so that the solution is backwards compatible. And perhaps more future proof.

wilkerlucio commented 6 years ago

@bhauman the PR that I sent uses the official react fallback for it; I guess this is the safest we can get.

bhauman commented 6 years ago

@wilkerlucio its a valid solution

It has its limitations though. It depends on another package, which will be probably be deprecated itself much sooner than we want.

It limits users to fairly recent React versions whereas the ability to extend React.Component has been around since React 14.

I guess I'm just saying that it's probably time we get onboard the train.

wilkerlucio commented 6 years ago

@bhauman not sure what you mean, according to React docs: https://facebook.github.io/react/docs/react-without-es6.html using the create-react-class package is the official way for people that don't want to go with ES6, as far as I understand this is not supposed to get deprecated any time soon.

wilkerlucio commented 6 years ago

@bhauman I mean, using the class syntax would mean having to support it on CLJS somehow, or rely on some ugly hacks with js*, do you think this is safer than using the create-react-class package? Or do you have something different in mind?

bhauman commented 6 years ago

This is indeed possible. You won't have to change any deps whatsoever if we extend React.Component.

bhauman commented 6 years ago

I've just worked this out in Devcards I can get you some example code.

wilkerlucio commented 6 years ago

I would like to see that, but being honest, I prefer using the official implementation for it, there are plenty of caveats in the create-react-class implementation, creating a custom thing instead of just using the official one has a much higher chance of missing some feature of that IMO.

bhauman commented 6 years ago

https://github.com/bhauman/devcards/blob/master/src/devcards/util/utils.clj#L8 https://github.com/bhauman/devcards/blob/master/src/devcards/core.cljs#L287

bhauman commented 6 years ago

I hear you, it is a bigger lift in this case to verify that everything is working correctly.

bhauman commented 6 years ago

Yeah after looking at it, it is a bit more invasive to make these changes to Om.

wilkerlucio commented 6 years ago

Thanks for the links, I'm glad you could make it work with so little. As you said, the change is not so simple in om codebase. Unless Facebook says something about the create-react-class package getting deprecated it should be safe for the foreseeable future.

nbardy commented 6 years ago

Any updates on this now that React 16.0 is out. From the looks of it this is all that is required to make om 16.0 compatible.