我有一个工作的React组件,它只是显示了一个封装在标头标签中的小字符串。由于它显示正常,我几乎肯定我的导入/导出设置是正确的。当我试图向我的<Spring />方法中添加一个render()组件时,我会看到:
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of Animation。
为什么<Spring>组件会在以前一切正常工作的情况下导致这种情况发生?我的代码如下:
import React from 'react';
import { Spring } from 'react-motion';
class Animation extends React.Component {
constructor(props){
super(props);
}
render() {
return (
<Spring defaultValue={0} endValue={120}>
{val => {
let style = {
height: val,
position: 'absolute'
}
return <div style={style}><h1>Hi!</h1></div>
}}
</Spring>
)
}
}
export default Animation;发布于 2016-09-06 11:04:34
React three不再公开使用道具和上下文作为React组件的Spring函数,相反,除了采用值和配置的spring函数(小写的‘s’‘)之外,您还可以使用三个函数,可以使用Motion、StaggeredMotion和TransitionMotion。查看反应运动回购上的最新文档。
https://stackoverflow.com/questions/38711889
复制相似问题