petehunt/famous-react

Adding support for Modifiers

Opened this issue · 2 comments

I know this repo is just a proof of concept, but I've been looking into Famous and it seems really well fitted to be integrated with React. Creating Famous components with JSX could be a lot easier then using the Famous API directly.

I tried looking into supporting more Famous objects but I'm not sure how to go about implementing stuff like Modifiers. In Famous when you create a Modifier you get an instance that you can keep for calling methods on it later on and you also add it to a context witch in turn creates a node. So it's not the Modifier constructor that creates a node, but the add function on the context.

Any ideas? I'm not really familiar with the React codebase, been using React for some time but didn't look much into what's going on "in the back". Is there some documentation of the code itself somewhere, other then the comments?

You may have already read my remarks on implementing famo.us modifiers in react: #1

A solid first step would be to fix the recursion strategy. There's also a pull request for the latest famo.us and a couple other bits needed to bring this repo closer to usable.

Ops, I skimmed trough that other thread before but didn't notice that remark.

Anyway what I tried doing for now is when creating the modifier, getting the parent node and adding the modifier to it so the result becomes the component's node. Also, the modifier should be attached to the React component so it can be referenced when the props change, for calling methods on it.

this.modifier = new Modifiers.StateModifier({})
this.node = this._owner._renderedComponent.node.add( this.modifier )

Not sure if it's in line with React's way of doing things but it seems to work at a first try. I'll keep investigating...