View当我的密码错误时,我想摇晃下面的内容。例如:
它应该是从位置 10 到位置 20 的 translateX 4 次 1 秒。然后应该停在原地 10。
放置 10(我的意思是 的 X 位置View)
startShake = () => {
Animated.loop(
Animated.sequence([
Animated.timing(this.animatedValue, {toValue: 1, duration: 150, easing: Easing.linear, useNativeDriver: true}),
Animated.timing(this.animatedValue, {toValue: -1, duration: 300, easing: Easing.linear, useNativeDriver: true}),
Animated.timing(this.animatedValue, {toValue: 0, duration: 150, easing: Easing.linear, useNativeDriver: true}),
])
).start();
}
<Animated.View style={{transform: [{
translateX: this.animatedValue.interpolate({
inputRange: [0, 0],
outputRange: [0, 0]
})
}]
}}>
</Animated.View>
Run Code Online (Sandbox Code Playgroud) 最近我安装了 macos 10.15 (catalina),我正在安装一些需要设置路径的软件,比如 java_home。
但我找不到 .bash_profile 或 .zshrc ?
我已将我class component的functional component钩子升级到钩子,但现在 ref 不起作用。
前:
class A extends Component{
animation = null;
onPress = ()=> {
this.animation.play();
}
render(){
return (
<View>
<LottieView
source={require('./file.json')}
ref={animation => {this.animation = animation}}
/>
<Button onPress={this.onPress} title='click me' />
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码,它是类Component工作得很好。
但是我升级的以下代码不起作用。
更新代码:
const A = props => {
const animation = useRef(null);
const onPress = ()=> {
animation.play();
}
return (
<View>
<LottieView
source={require('./file.json')}
ref={animation}
/>
<Button …Run Code Online (Sandbox Code Playgroud) 我有多个key, value,我不知道如何key, value在不同的地方存储多个。
是否有使用react-native-keychainpackage的以下代码的替代方法?
await AsyncStorage.setItem('pincode', '12345');
await AsyncStorage.setItem('userid', '@user8383928');
await AsyncStorage.setItem('contacts', JSON.stringify(contacts_array_of_object));
Run Code Online (Sandbox Code Playgroud)
以上每个都key, value saving可能在不同的函数和不同的时间调用。
问题在于react-native-keychain只有两个属性username, password:
async () => {
const username = 'zuck';
const password = 'poniesRgr8';
// Store the credentials
await Keychain.setGenericPassword(username, password);
try {
// Retrieve the credentials
const credentials = await Keychain.getGenericPassword();
if (credentials) {
console.log('Credentials successfully loaded for user ' + credentials.username);
} else {
console.log('No credentials stored');
}
} …Run Code Online (Sandbox Code Playgroud) 例
class AllWidget extends StatelessWidget{
@override
Widget build(BuildContext context){
print('state build called');
return ChangeNotifierProvider(
builder: (_) => MyCounter(),
child: Column(children: <Widget>[
MyCounterText(),
MyIncreaseButton(),
MyDecreaseButton(),
],
),
);
}
}
class MyCounterText extends StatelessWidget{
@override
Widget build(BuildContext context) {
final myCounter = Provider.of<MyCounter>(context, listen: false);
print('MyCounterText');
return Text(myCounter.num.toString());
}
}
class MyIncreaseButton extends StatelessWidget{
@override
Widget build(BuildContext context) {
final myCounter = Provider.of<MyCounter>(context, listen: false);
print('MyIncreaseButton');
return RaisedButton(
child: Text('Increase +'),
onPressed: ()=> myCounter.increament(),
);
} …Run Code Online (Sandbox Code Playgroud) 我有一个包含以下操作的列表:
useReducer()到数组中。useReducer()。useReducer()
。我需要最好、最安全的方式来更新我的列表。
目前我已经做了类似下面的事情,但它不能正常工作。
const reducer = (state, {type, value}) => {
switch(type){
case 'replacenewarray':
return value;
case 'additem':
return {...state, value}
case 'removeitem':
return state.filter(item => item.room !== value);
default:
return state;
}
}
Run Code Online (Sandbox Code Playgroud)
我的功能组件如下:
const newArray = [
{room: 'someroomid1', ....},
{room: 'someroomid2', ....},
{room: 'someroomid3', ....}
];
const itemToAdd = {room: 'someroomid4', ....};
const itemToRemoveWithRoomId = 'someroomid2';
export const Group = memo(props=> {
const [list, setList] …Run Code Online (Sandbox Code Playgroud) 我用Animatedfrom react-nativewith创建了一个简单的动画react-native-svg。
这工作做得很好,
但是现在我改用了,react-native-reanimated因为我在他们的网站上读到,reanimated 比Animatedfrom react-native.
但是在这里我遇到了一个问题,那就是我找不到addListener监听值变化的函数。
代码Animated来自react-native:
const circleRadius = new Animated.value(100);
circleRadius.addListener( circleRadius => {
circleSVG.current.setNativeProps({ cx: circleRadius.value.toString() });
});
Run Code Online (Sandbox Code Playgroud)
如何addListener在 react-native-reanimated.
javascript react-native react-native-svg react-native-reanimated
uid,当用户登录到火力使用第一次phone number。uid.然后,我创建了一个集合作为users与文件ID uid在像公司的FireStore: users/uid。
现在用户希望写进去users/userId,如果
condition是true象下面这样:
match /users/{userId} {
allow write: if request.auth.uid == userId;
}
Run Code Online (Sandbox Code Playgroud)
这里正如我所提到的number 2,userId是加密的,但未request.auth.uid加密。
那么我们如何在这里解密呢(userId)?
如果我使用散列 sha256,那么如何在客户端解码 sha256?
我在用 crypto-js
javascript firebase firebase-security google-cloud-firestore
我正在学习状态管理,flutter大部分时间遇到单词business logic ui logic,有一段时间presentation logic,我在互联网上搜索它,人们用不同的语言解释它,我无法更好地理解,有人可以展示这三种类型logic以一个例子的形式解释它很干净和容易吗?
最近更新了@react-native-firebase/auth,现在Recaptcha verifier更新的版本里有添加。
但我不想,即使我没有配置任何Recaptcha,但它在使用电话号码登录时会自动打开react-native,这不是一个好的体验。
我怎样才能禁用它,这可能吗?
firebase react-native firebase-authentication react-native-firebase
react-native ×6
dart ×2
firebase ×2
flutter ×2
javascript ×2
react-hooks ×2
bloc ×1
flutter-bloc ×1
macos ×1
provider ×1
reactjs ×1