gpt4 book ai didi

react-native - 使用react-spring进行react-native

转载 作者:行者123 更新时间:2023-12-04 18:34:50 25 4
gpt4 key购买 nike

我想将此库用于 native react ,但不知道如何操作。 react-native的文档链接已损坏。我可以使用该库进行react-native吗?

最佳答案

React-Spring可用于react-native。他们已经为所有平台更新了它。
试试这个:
yarn add react-spring@5.3.0-beta.0

import React from 'react'
import { StyleSheet, Text, View, TouchableWithoutFeedback } from 'react-native'
import { Spring, animated } from 'react-spring/dist/react-spring-native.esm'

const styles = {
flex: 1,
margin: 0,
borderRadius: 35,
backgroundColor: 'red',
alignItems: 'center',
justifyContent: 'center',
}

export default class App extends React.Component {
state = { flag: true }
toggle = () => this.setState(state => ({ flag: !state.flag }))
render() {
const { flag } = this.state
return (
<Spring native from={{ margin: 0 }} to={{ margin: flag ? 100 : 0 }}>
{props => (
<TouchableWithoutFeedback onPressIn={this.toggle}>
<animated.View style={{ ...styles, ...props }}>
<Text>It's working!</Text>
</animated.View>
</TouchableWithoutFeedback>
)}
</Spring>
)
}
}

`
enter image description here

关于react-native - 使用react-spring进行react-native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52733390/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com