μ¬μ© μ€μΈ λ²μ μ μλ €μ£Όμμμ€.
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
λ₯Ό μλνκ³ Componentλ₯Ό μ λ¬νμμμ€.
@kesha-antonov μλνμ§ μμ΅λλ€. λλ μ΄κ²μ μν΄ μλ‘μ΄ λ¬Έμ λ₯Ό λ§λλλ€.
κ·Έκ²μ λλ₯Ό μν΄ μλν©λλ€. rnrf-4-λ² ν22
leftButton
μΌμͺ½ μμ΄μ½
right
μ€λ₯Έμͺ½ μμ΄μ½
κ³΅κ° componentWillMount(): λ¬΄ν¨ {
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 });
λ λ²μ§Έλ‘ μλνμ§ μμ
https://github.com/aksonov/react-native-router-flux/issues/2862
@aksonov
@jaysassyinfotech
Actions.refresh({ ν€: Actions.currentScene }); λ λ²μ§Έλ‘ μλνμ§ μμ
μ΄λ κ² νλ©΄ μ λ©λλ€ :)
Actions.refresh({ν€: Math.random()})
@cosinus84 λΉμ μ μλͺ μ μμΈμ λλ€.
@cosinus84 μ λ§ μΌμ
λλ€. μ
κ·Έλ¬λ Math.random()μ΄ λͺ¨λ νΈλ¦μ μννλ μ΄μ μ λν μ€λͺ
μ΄ μμ΅λκΉ?
@cosinus84 λΉμ μ λ‘맨 (y)
μ΄μ μ΅μ λ²μ μλ 무μμκ° νμνμ§ μκΈ°λ₯Ό λ°λλλ€.
@aksonov μ₯λ©΄ μνμ΄ μ¬κΈ°μμ μλνμ§ μλ κ² κ°μμ Actions.refresh()μμ μ¬μ©ν μ μλ μν(ν΄λΉ κΈ°λ₯ ν¬ν¨)μ λμ΄ν΄ μ£Όμκ² μ΅λκΉ?
μμ μ±κ³Ό μλ‘ κ³ μΉ¨ νΈμΆμ νμΈν μ μμ΅λλ€. μ΅μ 4.0.5μμλ μ μλν©λλ€. λ¬Έμ λ₯Ό μ€λͺ νκΈ° μν΄ μμ λ‘κ² μμ λ₯Ό 볡μ νκ³ μμ νμμμ€.
μ, μ μλνμ§λ§ μΈμ μ΄λ€ κ²μ μ¬μ©ν΄μΌ ν μ§ λͺ¨λ₯Ό μ μμΌλ―λ‘ μλ‘ κ³ μΉ¨ νΈμΆμ μ¬μ©ν props λͺ©λ‘μ λ§λλ κ²μ΄ μ’μ΅λλ€.
μλ₯Ό λ€μ΄ λ€λ‘ λ²νΌμ λ λλ§νλ €λ©΄ leftButton
μνμ μ¬μ©ν΄μΌ νμ§λ§ @kesha-antonovμ λκΈμ μ½μ λκΉμ§ λͺ°λμ΅λλ€.
κ·Έκ²μ μλ
@preetluv μ΄λ»κ² κ³ μ³€λμ§ λ§μν΄ μ£Όμκ² μ΅λκΉ?
@preetluv cosinus84 μ λ΅λ³ μ°Έμ‘°
λ€μμ μνν μ μμ΅λλ€ .
μ‘μ .ν()
setTimeout(()=> Actions.refresh({"somePropToRefresh":Math.random(),"yourProp":"μλ‘ κ³ μΉ¨
λμκ° λμ μ΄μ νλ©΄"}),0.5);
backμ ν ν μ΄μ νλ©΄μ componentWillReceiveProps μμ "yourProp"μ νμΈν μ μμ΅λλ€.
react-native-router-flux 4.2.0-beta.2
λ₯Ό μ¬μ©νκ³ setTimeout κ³Ό ν¨κ» μλν©λλ€.
κ°μ₯ μ μ©ν λκΈ
@jaysassyinfotech
Actions.refresh({ ν€: Actions.currentScene }); λ λ²μ§Έλ‘ μλνμ§ μμ
μ΄λ κ² νλ©΄ μ λ©λλ€ :)
Actions.refresh({ν€: Math.random()})