2016-08-02 56 views
0

我有一個工作的React組件,它只是顯示一個包裹在標題標籤中的小字符串。由於它顯示正常,我幾乎肯定我的導入/導出設置正確。當我嘗試將<Spring />組件添加到我的render()方法中時,我得到:引起不變違規的React-Motion Spring組件

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; 

回答

1

反應運動不再暴露Spring函數,它的道具和背景用作陣營組件,而不是你有,你可以用功能MotionStaggeredMotionTransitionMotion在除了spring功能(與小寫''),它需要值和配置。查看關於Github上react-motion repo的最新文檔。

相關問題