chenglou / react-tween-state

React animation.
Other
1.74k stars 70 forks source link

React 0.13 and es6 Classes #26

Closed jmfurlott closed 8 years ago

jmfurlott commented 9 years ago

Is it possible to use react-tween-state with the new class style? Can't use mixins anymore, so what would it take for this to work?

natew commented 9 years ago

I think just moving the need for tweenQueue to be in state and instead put it on the class itself, and then adding this to the prototype somehow.

natew commented 9 years ago

I implemented as a mixin that works here, you can even use it as a decorator with babel 5:

https://github.com/reapp/reapp-ui/blob/master/src/decorators/Tweenable.js

@Tweenable
class MyClass extends React.Component {}
chicoxyzzy commented 9 years ago

:+1:

frederickfogerty commented 9 years ago

@natew this errors, as trying to assign getInitialState on a plain class is not supported at the moment.

natew commented 9 years ago

@frederickfogerty If you use it with my pull request on this repo it should work, may be some bugs but it works for me.

frederickfogerty commented 9 years ago

Will have a look now :+1:

chrisvfritz commented 9 years ago

:+1: Would also love to see this work without mixins. Component wrappers are a popular alternative that will not only work with ES6 classes, but also CoffeeScript, TypeScript, LiveScript, etc.

rob-balfre commented 9 years ago

:+1:

frederickfogerty commented 9 years ago

To be honest, we should all just use https://github.com/chenglou/react-motion. I'm moving all my tween-state code to it at the moment

rob-balfre commented 9 years ago

@frederickfogerty nice, will take a look. Thanks!

chenglou commented 8 years ago

I think I'll keep this library as a mixin. React-motion already fills most of the transition needs and if the demand is high for normal easing, I'll implement it over there. This library's stable, and changing the API to use classes breaks too many existing call sites. Besides, React might move away from classes now.

Closing! Thanks for all the discussion. Go check React-motion! =)

chrisvfritz commented 8 years ago

React might move away from classes now.

This caught my interest as I teach React and want to make sure I'm up to date. I thought ES6 classes were enouraged. Did I miss an announcement somewhere?

chenglou commented 8 years ago

Nah it's a might. So no news worth spreading for now. Check https://github.com/reactjs/react-future

Also: https://twitter.com/sebmarkbage/status/646473000749928448

chrisvfritz commented 8 years ago

Thanks! I gotta stay on top of these tweets. :smiley: