yahoo/fluxible

Replace createReactClass with ES6 classes

alexparish opened this issue · 8 comments

The module create-react-class is a dependency of both fluxible-addons-react and fluxible-router and as such will bloat any projects that consume these packages.

Instances of createReactClass should be replaced with ES6 classes that extend React.Component such that the dependency on the create-react-class module can be removed.

@alexparish Good point. For fluxible-addons-react that package is actually only used for testing, so we could move the dependency to devDependencies to avoid the extra bloat.

For fluxible-router, we could refactor that away too. We would have to ensure we are not leveraging mixins or anything to ensure we do not break functionality.

Published in fluxible-addons-react@0.2.13

This issue seems more pressing now React 16 has launched.

This latest version of React has removed the dependency on create-react-class but fluxible-router still has a dependency on it.

@alexparish Shouldn't be an issue with React 16 because we are using the create-react-class package instead of relying on React.createReactClass directly.

@redonkulus Sure, I understood that nothing will break.

My concern was the bloat of bringing in that extra package. Removing the dependency (and using ES6 classes instead) would shave 12.5K from my bundle. Not huge, but it seems an unnecessary dependency.

I will look into creating a PR for this if I can find time.

I believe there is only one place that uses createReactClass at this point: https://github.com/yahoo/fluxible/blob/master/packages/fluxible-router/lib/createNavLinkComponent.js

I migrated everything to use ES5 classes in 9c46478 but did not migrate that one case for a reason I can't remember. It may be a backward incompatibility but I can't remember.

I have created a PR to remove that final instance of createReactClass

Updated PR created: #586