反应导航:利用Redux深层链接
问题描述:
在反应导航中,可以通过将uriPrefix
prop传递给顶层导航器,或将{containerOptions: {URIPrefix: PREFIX}}
作为第二个参数传递给内置导航器(例如StackNavigator
)来利用深度链接。反应导航:利用Redux深层链接
当Redux与React Navigation集成时,顶层导航器会通过一个navigation
支柱。
但是,在RN应用上同时启用Redux和Deep Link时。 uriPrefix
和navigation
道具都需要传递到顶级导航仪,它抛出一个错误,
该导航仪具有导航和集装箱的道具,所以它是 不清楚是否应该拥有自己的状态。
const S1 =() => <View><Text>S1 text</Text></View>;
const S2 =() => <View><Text>S2 text</Text></View>;
const S3 =() => <View><Text>S3 text</Text></View>;
const AppNav = StackNavigator(
{
S1: {screen: S1, path: 's1'},
S2: {screen: S2, path: 's2'},
S3: {screen: S3, path: 's3'}
}
);
@connect(state => ({nav: state.nav}))
class App extends Component {
render() {
const
{ dispatch, nav } = this.props,
uriPrefix = Platform.OS == 'android' ? 'http://localhost/' : 'http://';
return (
<AppNav
navigation={addNavigationHelpers({dispatch: this.props.dispatch, state: this.props.nav})}
uriPrefix={uriPrefix}
/>
);
}
}
const navReducer = (state, action) => (AppNav.router.getStateForAction(action, state) || state);
const rootReducer = combineReducers({nav: navReducer});
const RootApp = props =>
<Provider store={createStore(rootReducer)}>
<App />
</Provider>;
export default RootApp;
如何终极版和(使用阵营导航)深层链接都被集成在RN的应用程序?