小编Ted*_*ppe的帖子

使用 Next.js 的 GSAP ScrollTrigger

我正在尝试ScrollTrigger与 Next.js一起使用:

import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";

gsap.registerPlugin(ScrollTrigger);
Run Code Online (Sandbox Code Playgroud)

我收到此错误: 在此处输入图片说明

有没有人有这个问题的解决方案?

javascript reactjs gsap next.js

5
推荐指数
1
解决办法
649
查看次数

使用钩子设置活动类名

我正在尝试将我的一些类组件转换为功能组件。但是我的“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)

javascript reactjs react-hooks

3
推荐指数
1
解决办法
4440
查看次数

如何在 React Native 中处理带有状态的动画计时

我试图在按下 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)

javascript react-native react-native-reanimated

1
推荐指数
1
解决办法
1953
查看次数