The navigation object hasn't been initialized yet.
#1019
|
I have a screen with a list of items. I would like to navigate to a screen for details of one of items. I setup the I also have a basic <navigator id="root" type="stack">
<nav-route id="home" href="{{ url('hv.home_screen') }}"></nav-route>
@foreach ($nourishments as $nourishment)
<nav-route id="menu-item-{{ $nourishment->id }}" href="{{ route('hv.menu_item_screen', $nourishment->id) }}"></nav-route>
@endforeach
</navigator>(I'm not sure if I need the When I try to navigate, I get an error:
Anybody know why that might be? // App.tsx
<NavigationContainer>
<BottomTabBarContextProvider>
<Hyperview
behaviors={Behaviors}
components={Components}
entrypointUrl={`${Constants.expoConfig?.extra?.baseUrl}/hv`}
fetch={fetchWrapper}
formatDate={formatDate}
logger={new Logger(Logger.Level.log)}
navigationComponents={{
BottomTabBar,
}}
/>
</BottomTabBarContextProvider>
</NavigationContainer>If I understand correctly, I shouldn't have to mess with the contents of |
Replies: 2 comments 4 replies
|
@killianarts, thanks for reaching out. The problem may be related to your navigation hierarchy. You do not need to create a unique Example navigation: Example Home Screen: You can find examples of using "new", "push" and other navigation behaviors in the "Navigation" section of the demo under "Behaviors/Actions". The second problem you encountered is If this doesn't resolve your issues, could you please let us know where you were trying to trigger the behavior? |
|
Thanks Mr. Gray. I kinda figured that I didn't need the extra nav-route stuff for each item. Thanks for clarifying for me. My "home" endpoint is where I have the following code: <doc xmlns="https://hyperview.org/hyperview">
<navigator id="root" type="stack">
<nav-route id="home" href="{{ route('hv.home_screen') }}"></nav-route>
</navigator>
<screen>
<styles>
...
</styles>
<body scroll="true">
<header>
<text style="Header">
Menu
</text>
</header>
<view style="menu-container">
@foreach ($nourishments as $n)
<view style="menu-item">
<image style="Image" source="{{ asset('storage/' . $n->image_url) }}" />
<text style="menu-item--item-name">
{{ $n->name }}
</text>
<view style="menu-item--button-container">
<text style="menu-item--price">
¥{{ $n->s_price }}
</text>
<view style="main-button">
<behavior trigger="press" href="{{ route('hv.menu_item_screen', $n->id) }}" action="new"></behavior>
<image style="icon" source="{{ asset('storage/img/android/drawable-xxxhdpi/bag_shopping.png') }}" />
<text style="button-text">
Add
</text>
</view>
</view>
</view>
@endforeach
</view>
</body>
</screen>
</doc>The behavior looks similar to the code examples you provided: <behavior trigger="press" href="{{ route('hv.menu_item_screen', $n->id) }}" action="new"></behavior>I also tried I still get the navigation object error. I've confirmed in a web browser that the rendered href's are correct. |
Ah, the problem here is that your
<doc>cannot contain both a navigator and a screen. Your entry point url should point to a document that contains only the<doc><navigator.../></doc>structure. You then need to create a second document which contains the<doc><screen .../></doc>structure for the "home" page. The url for that second document goes into the single<nav-route>you have provided.index.xml
home.xml
There are some additional samples in the Guide section of our website that you might find useful, under the "Hyperview Navi…