0
我已經在下面設置了我的子步行導航器,第一個場景,PCDrinkingDays
工作正常。然而,當我點擊派遣一個動作,從該組件來改變場景:react-navigation,調度動作改變場景 - 場景不顯示
onDone =() => {
this.props.dispatch(navigate(scenes.PC_HELP_ME_CALCULATE));
};`
的PCHelpMeCalculate
,未出現,雖然我可以看到它呈現在通過設置斷點背景。
我的導航器位於下方。其他場景看起來沒問題,它剛剛從第一個場景移動,似乎是問題。誰能幫忙?爲什麼不顯示組件?
import { SubStepsNavigator } from '../../../navigators';
import PCDrinkingDays from '../PCDrinkingDays';
import PCHelpMeCalculate from '../PCHelpMeCalculate';
import PCUnitsCalculatorWhat from '../PCUnitsCalculatorWhat';
import PCUnitsCalculatorSize from '../PCUnitsCalculatorSize';
import PCUnitsCalculatorStrength from '../PCUnitsCalculatorStrength';
import PCUnitsCalculatorDrinksNumber from '../PCUnitsCalculatorDrinksNumber';
import PCUnitsCalculatorTable from '../PCUnitsCalculatorTable';
import * as scenes from '../../../scenes';
const PCDrinkingScenes = {
[scenes.PC_DRINKING_DAYS]: { screen: PCDrinkingDays },
[scenes.PC_HELP_ME_CALCULATE]: { screen: PCHelpMeCalculate },
[scenes.PC_UNITS_CALCULATOR_WHAT]: { screen: PCUnitsCalculatorWhat },
[scenes.PC_UNITS_CALCULATOR_SIZE]: { screen: PCUnitsCalculatorSize },
[scenes.PC_UNITS_CALCULATOR_STRENGTH]: { screen: PCUnitsCalculatorStrength },
[scenes.PC_UNITS_CALCULATOR_DRINKS_NUMBER]: {
screen: PCUnitsCalculatorDrinksNumber,
},
[scenes.PC_UNITS_CALCULATOR_TABLE]: { screen: PCUnitsCalculatorTable },
};
function getStep(routeName) {
switch (routeName) {
case scenes.PC_DRINKING_DAYS:
case scenes.PC_HELP_ME_CALCULATE:
case scenes.PC_UNITS_CALCULATOR_WHAT:
case scenes.PC_UNITS_CALCULATOR_SIZE:
case scenes.PC_UNITS_CALCULATOR_STRENGTH:
case scenes.PC_UNITS_CALCULATOR_DRINKS_NUMBER:
case scenes.PC_UNITS_CALCULATOR_TABLE:
return 1;
default:
console.log(`ERR not found step for route ${routeName}`);
return -1;
}
}
const stepsOptions = {
nSteps: 2,
getStep,
};
const PCDrinkingNavigator = SubStepsNavigator(
PCDrinkingScenes,
{ navigationOptions: { gesturesEnabled: false }, headerMode: 'none' },
stepsOptions
);
export default PCDrinkingNavigator;
我派遣我的分量我的行動:
class PCDrinkingDays extends Component {
onDone =() => {
this.props.dispatch(navigate(scenes.PC_HELP_ME_CALCULATE));
};
render() {
return (
<SceneSelectNumber
goBack={this.goBack}
onChangeNumber={this.onChangeNumber}
selectedNumberValue={this.props.daysInAweek}
onDone={this.onDone}
sceneConfig={sceneConfig}
/>
);
}
}
更新了我的問題,我在組件調度。 – Bomber
但問題似乎是,您使用'this.props.dispatch'而不是'this.props.navigation.dispatch' –