diff --git a/src/Controller.js b/src/Controller.js index 5a37f4a..cdb29df 100644 --- a/src/Controller.js +++ b/src/Controller.js @@ -16,6 +16,8 @@ export type ControllerState = { controller: ?any, } +const ControllerContext = React.createContext(null); + class Controller extends React.Component { controller: any; @@ -42,14 +44,12 @@ class Controller extends React.Component { return children; } - return React.Children.map(children, (child) => { - if (child.type.displayName !== 'Scene') { - return child; - } - const props = {...child.props, controller}; - return ; - }); + return ( + + {children} + + ); } } -export { Controller }; +export { Controller, ControllerContext }; diff --git a/src/Scene.js b/src/Scene.js index b5418bd..0b2f134 100644 --- a/src/Scene.js +++ b/src/Scene.js @@ -1,5 +1,6 @@ // @flow import { default as React } from 'react'; +import { ControllerContext } from './Controller'; import ScrollMagic from './lib/scrollmagic'; import debugAddIndicators from './lib/debug.addIndicators.js'; @@ -228,7 +229,7 @@ class SceneBase extends React.PureComponent { } } -class Scene extends React.PureComponent { +class SceneWrapper extends React.PureComponent { static displayName = 'Scene'; render() { @@ -246,4 +247,12 @@ class Scene extends React.PureComponent { } } -export { Scene }; +export const Scene = ({ children, ...props }) => ( + + {controller => ( + + {children} + + )} + +); \ No newline at end of file