私はreact-native-ui-kittenのRkSwitchコンポーネントを使用しています。パッケージは私が使うことができるUIコンポーネントの束です。onValueChangeが既存のコンポーネントで動作しない
開発者はコンポーネントをサポートしなくなり、私のRkSwitchコンポーネントは期待通りに機能しません。
私の問題はRkSwitch
のonValueChangeは何もしません。
render function for android < - 機能しません。 (問題)
render function for iOS < - まだテストされていませんが、動作するはずです。
私はRkSwitchと呼ばれました。 RkSwitchは反応ネイティブの<Animated.View>
のラッパークラスであるため、onValueChangeを渡すことはできません。
<RkSwitch
style={styles.switch}
value={this.state.onlyMe}
name="Push"
onValueChange={
(onlyMe) => {
console.log('helloworld'); // it can't print helloworld
}
}
/>
ここにはRkSwitchの実際のコードがあります。 (これはアンドロイド版です)。 Doc Link
_onPanResponderRelease = (evt, gestureState) => {
let {toggleable} = this.state;
let {disabled, onValueChange} = this.props;
if (toggleable && !disabled) {
if (onValueChange) { // calls onValueChange and..?
this.toggleSwitch(onValueChange) // call toggle switch
}
}
};
toggleSwitch = (result, callback =() => null) => {
let {value, switchAnimation} = this.state;
let toValue = !value;
this.animateHandler(this.handlerSize);
this.animateSwitch(toValue,() => {
callback(toValue);
this.setState({
value: toValue,
left: toValue ? onLeftValue : offLeftValue
});
switchAnimation.setValue(toValue ? -1 : 1)
})
それは彼らがonValueChangeの小道具を処理しているようだが、それは動作しません。良いJavascriptやReactのエキスパートはありますか?
私はそれをテストし、それは働いた。 THANKS –