使用しているバージョンを教えてください。
Actions.refresh()は、現在のシーンを更新します。
私のアプローチが間違っていた場合、またはActions.refreshにいくつかの要件がある場合は、情報を提供してください
const ConnectRouter = connect()(Router);
const Routes = () => (
<ConnectRouter>
<Scene key="root">
<Scene key="launchScreen" component={LoadingFull} hideNavBar />
<Scene key="login" component={LoginForm} hideNavBar type={ActionConst.RESET} />
<Scene key="lostPassword" component={LostPasswordForm} hideNavBar />
<Scene key="dashboard" component={Dashboard} hideNavBar type={ActionConst.RESET} />
<Scene key="search" component={SearchResult} hideNavBar />
</Scene>
</ConnectRouter>
);
検索シーン(状態のあるプレーンコンポーネント)にいるとき、Actions.refreshを使用してシーンを更新しようとしていました。 しかし、どういうわけかそれはまったく機能しませんでした。
+1
シーンからrenderBackButtonを使用したい。 私のサンプルコード、
public componentWillMount (): void {
Actions.refresh({
renderBackButton: this.renderBackButton.bind(this),
onRight: this.onRightButtonPress.bind(this)
});
}
動いていない。 同じ問題だと思います。
$#$ renderBackButton
leftButton
を試して、コンポーネントを渡します。
@kesha-antonov動作していません。 このための新しい問題を作成します。
わたしにはできる。 rnrf-4-beta22
左アイコンのleftButton
右のアイコンright
public componentWillMount():void {
this.props.navigation.setParams({
onRight:()=> {this.myOnRight();}、
rightTitle:'newTitle'、
});
}
それは私のために働いています。
イエス様、私は元の問題の答えを探してここに来ました。
関連のない問題に便乗しないようにしてください!
同じ問題が発生していますが、ストア( mobx )を更新するときに
<strong i="7">@observer</strong>
class Custom extends Component {
render() {
// prints every time I update state, this's ok!
console.log('update', store.session.get('logged'))
return (
<Router>
<Scene key="root">
<Scene key="login"
component={login}
type="replace"
onEnter={() => {
// ONLY enter here once
console.log('onEnter');
return store.session.get('logged')
}}
success="recents"
/>
<Scene key="recents" component={recents} />
</Scene>
</Router>
)
}
}
ストアの更新後にActions.refresh()
を呼び出す「再レンダリング」をトリガーしようとしましたが、 onEnter
が応答しません。
_onPressButton() {
store.session.set('logged', !store.session.get('logged')) // invert the value in store
Actions.refresh() // tested with { key: 'login' } too
}
@aksonov正しい方向を教えていただけませんか。 :祈る:
やあ
同じ問題があります...Actions.refresh()で更新しようとしても何も起こりません
import React, { Component } from 'react';
import {
View,
Text,
Button,
} from 'react-native';
import { Actions } from 'react-native-router-flux';
export default class Types extends Component {
constructor(props) {
super(props);
console.log("Constructor Types")
}
componentWillMount() {
console.log('Will mount Types')
}
componentWillUpdate() {
console.log("Will Update Types")
}
componentWillUnmount() {
console.log("will Unmont Types")
}
render() {
console.log("render Types")
return (
<Button title='refresh' onPress={() => Actions.refresh()}/>
)
}
}
ここでも同じ問題があります。reduxを使用していますが、右ボタンを更新しようとしても更新されません。
サンプルプロジェクトで問題を再現してください。
Actions.refresh({ key: Actions.currentScene });
が2回目に機能しない
https://github.com/aksonov/react-native-router-flux/issues/2862
@aksonov
@jaysassyinfotech
Actions.refresh({key:Actions.currentScene}); 2回目は動作しません
あなたがこれを好きならそれは働きます:)
Actions.refresh({key:Math.random()})
@cosinus84あなたは命の恩人です。
@cosinus84それは本当に仕事です。 おお
しかし、Math.random()がすべてのトリックを行う理由について何か説明はありますか?
@ cosinus84あなたはロックマン(y)
うまくいけば、最新バージョンではランダムは必要ありません
@aksonovシーンの小道具がここでは機能していないように見えるので、Actions.refresh()で使用できる小道具(関数を含む)をリストアップしてください。
Exampleアプリとその更新呼び出しを確認できます。最新の4.0.5では正常に機能します。 問題を示すために、それに応じて例を複製して変更してください。
はい、正常に機能していますが、いつ使用するかわからない場合があるため、refresh呼び出しで使用する小道具のリストを作成することをお勧めします。
たとえば、戻るボタンをレンダリングするには、 leftButton
プロップを使用する必要がありますが、@ kesha-antonovのコメントを読むまで、それはわかりませんでした。
その働き
@preetluv心はあなたがそれをどのように修正したか教えてくれますか?
@preetluvcosinus84の回答を参照
次のことができます:-
Actions.pop()
setTimeout(()=> Actions.refresh({"somePropToRefresh":Math.random()、 "yourProp":"を更新するには
前の画面に戻る"})、0.5);
戻った後、前の画面のcomponentWillReceivePropsで「yourProp」を確認できます。
react-native-router-flux 4.2.0-beta.2
を使用し、 setTimeoutで動作します
最も参考になるコメント
@jaysassyinfotech
Actions.refresh({key:Actions.currentScene}); 2回目は動作しません
あなたがこれを好きならそれは働きます:)
Actions.refresh({key:Math.random()})