gpt4 book ai didi

react-native - react 导航 : Utilizing deep linking with Redux

转载 作者:行者123 更新时间:2023-12-04 12:45:52 25 4
gpt4 key购买 nike

在 React Navigation 中,可以通过传递 uriPrefix 来使用深层链接。支持顶级导航器,或通过 {containerOptions: {URIPrefix: PREFIX}}作为内置导航器的第二个参数(例如 StackNavigator )。

当 Redux 与 React Navigation 集成时,顶级导航器会传递一个 navigation支柱。

但是,在 RN 应用程序上同时启用 Redux 和深度链接时。 uriPrefixnavigation prop 都需要传递给顶级导航器,这会引发错误,

This navigator has both navigation and container props, so it is unclear if it should own its own state.


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;

Redux 和深度链接(使用 React Navigation)如何集成到 RN 应用程序中?

最佳答案

关于react-native - react 导航 : Utilizing deep linking with Redux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43544589/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com