<FramesCollection>
<Frames1 speed='1.0' width='auto' zIndex='1' />
<Frames2 speed='1.2' width='auto' zIndex='1' />
<Frames3 speed='1.4' width='auto' zIndex='1' />
<Frames4 speed='1.6' width='auto' zIndex='1' />
<Frames5 speed='2.0' width='auto' zIndex='4' />
<Frames6 speed='2.5' width='auto' zIndex='3' />
<Rails />
</FramesCollection>
をFramesCollectionで:
render() {
const { selectedItem, menuItems } = this.props.bottomMenu
const col = menuItems.length
const springSettings = { stiffness: 170, damping: 26 };
return (
<aside className='frames-collection' ref='framesCollection'>
{React.Children.map(
this.props.children,
(child, i) => {
if ('speed' in child.props) {
const width = Math.round(child.props.speed * col * 2000)
const style = { width: width, translateX: spring(-width * selectedItem, springSettings) }
return <Motion key={i} style={style}>
{child}
</Motion>
} else {
return child;
}
})
}
</aside>
)
}
コードがエラーなしでコンパイルされているが、ブラウザのほかにI 2つのエラーを参照してください。
Warning: Failed prop type: Invalid prop
children
of typeobject
supplied toMotion
, expectedfunction
. in Motion (created by FramesCollection) in FramesCollection (created by Connect(FramesCollection)) in Connect(FramesCollection) (created by App) in div (created by App) in App (created by Connect(App)) in Connect(App) in div in Provider
そして
Uncaught TypeError: this.props.children is not a function at Object.render (Motion.js:235) at ReactCompositeComponent.js:796 at measureLifeCyclePerf (ReactCompositeComponent.js:75) at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:795) at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js:822) at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:362) at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:258) at Object.mountComponent (ReactReconciler.js:46) at ReactDOMComponent.mountChildren (ReactMultiChild.js:238) at ReactDOMComponent._createInitialChildren (ReactDOMComponent.js:697)
私は間違っていますか?
ドキュメントは、モーションに関数を渡すことを明確に示しています。 https://github.com/chenglou/react-motion。そして、それはまさにエラーが言っていることとまったく同じように起こります。 – Gimby
詳細はお答えください。何もわからなかった。 – alexandr2006