我正在尝试ScrollTrigger与 Next.js一起使用:
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
gsap.registerPlugin(ScrollTrigger);
Run Code Online (Sandbox Code Playgroud)
有没有人有这个问题的解决方案?
我正在尝试将我的一些类组件转换为功能组件。但是我的“toogle”活动类不能使用钩子,请问我做错了什么,这是我的脚本。
import React from "react";
import "./styles.css";
export default class ActiveState extends React.Component {
constructor(props) {
super(props);
this.state = {
activeIndex: 0
};
}
handleOnClick = index => {
this.setState({ activeIndex: index });
};
render() {
const boxs = [0, 1, 2, 3];
const box = boxs.map((el, index) => {
return (
<button
key={index}
onClick={this.handleOnClick.bind(this, index, this.props)}
className = {this.state.activeIndex === index ? "active" : "unactive"}
>
{el}
</button>
);
});
return <div className="App">{box}</div>;
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我尝试使用钩子的方法,但不起作用:
import React, { …Run Code Online (Sandbox Code Playgroud) 我试图在按下 TouchableOpacity 组件时增加视图的高度,但它不起作用。我做错了什么 ?我应该使用生命周期组件吗?
import * as React from "react";
import {
View
} from "react-native";
import * as Animatable from "react-native-animatable";
import Animated from "react-native-reanimated";
const Screen_Height = Dimensions.get("window").height;
class RegistrationView extends React.Component {
state = {
registrationHeight: new Animated.Value(150),
};
increaseHeight = () => {
Animated.timing(this.state.registrationHeight, {
toValue: Screen_Height,
duration: 500
}).start();
};
render() {
return (
<Animated.View
style={{
height: this.state.registrationHeight
}}
>
<TouchableOpacity onPress={() => this.increaseHeight()}>
<View>
<Text>
Welcome, press here.
</Text>
</View>
</TouchableOpacity>
</Animated.View>
)
} …Run Code Online (Sandbox Code Playgroud)