Closed jesperlandberg closed 8 years ago
I don't se any problem in this piece of code :(, did you try to check what this
is if it is not what it should be?
Hi, did you managed to resolve this problem?
Hi! I have the exact same error:
My code:
import React from 'react';
import GSAP from 'react-gsap-enhancer';
import { TimelineMax } from 'gsap';
import AccountView from './view';
import AuthService from '../../services/AuthService';
function appearAnim({target}) {
// const duration = 0.5;
// return new TimelineMax()
// .to()
}
function errorAnim({target}) {
// const duration = 0.5;
// return new TimelineMax()
}
class Account extends React.Component {
constructor(props) {
super(props);
console.log(this)
this.errorAnim = this.addAnimation(errorAnim);
this.state = {
isAccountMenuVisible: false,
isSignUpVisible: true,
error: null,
}
}
componentDidMount() {
this.addAnimation(appearAnim);
}
handleSignIn = (e) => {
const email = e.target.elements['email'].value.trim();
const password = e.target.elements['password'].value.trim();
e.preventDefault();
AuthService.signIn(email, password);
}
handleSignUp = (e) => {
const email = e.target.elements['email'].value.trim();
const password = e.target.elements['password'].value.trim();
e.preventDefault();
AuthService.signUp(email, password).then(() => {
AuthService.signIn(email, password);
}).catch((error) => {
this.setState({
error
});
});
}
showSignUp = (e) => {
this.setState({
isSignUpVisible: true
});
e.preventDefault();
}
showSignIn = (e) => {
this.setState({
isSignUpVisible: false
});
e.preventDefault();
}
render() {
const { isSignUpVisible, isAccountMenuVisible, error } = this.state;
const { styles } = this.props;
return(
<AccountView
isSignUpVisible={isSignUpVisible}
handleSignIn={this.handleSignIn}
handleSignUp={this.handleSignUp}
showSignUp={this.showSignUp}
showSignIn={this.showSignIn}
/>
)
}
}
export default GSAP()(Account);
Browser throws:
TypeError: _this.addAnimation is not a function
console.log on "this" shows there is "removeAnimation" method but no addAnimation.
Any idea?
@mmintel Today I also had the same problem and found that addAnimation
can't be inside constructor
. It works well in componentDidMount
.
I ended up using GSAP without plugin like described here https://medium.com/@marcmintel/react-meets-gsap-c6dd82edeb72
Hi,
I get the error message "this.addAnimation(btnEnter) is not a function".
What is wrong with my code?