question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Layout] "treeProps" does not render any nav items

See original GitHub issue

I’m currently following the steps at https://react-md.dev/guides/configuring-your-layout.

I have a component which renders the layout:

const MainLayout = (props) => {
    const {pathname} = useLocation();
    const navItems = {
        "/": createRoute("/", "Home", <HomeSVGIcon />),
        "/about": createRoute("/about", "About", <HelpSVGIcon/>),
    };

    return (
        <Layout
            treeProps={useLayoutNavigation(navItems, window.location.pathname)}
            appBarTitle="react-md App"
            navHeaderTitle="My App"
            title="Title"
        >
            <App/>
        </Layout>
    );
};

My createRoute function looks the same like in the documentation:

function createRoute(pathname, children, leftAddon, parentId) {
    return {
        itemId: pathname,
        parentId,
        to: pathname,
        children,
        leftAddon,
    };
}

There isn’t rendered anything in the navigation drawer.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mlaursencommented, Jun 30, 2020

Just happened to be great timing that I checked this right as I was stopping work for the day 😃

I’ve updated the docs to hopefully explain this a bit better as well as some outdated notes for adding a transition to the Layout component. Just let me know if I should try a different way of documenting this and I’ll reopen this issue.

1reaction
mlaursencommented, Jun 29, 2020

Yeah, it’s the buildTree and useNestedTreeList utils for building a tree list from an object. Since the useNestedTreeList defaults to having the rootId set to null, we also need the routes to have a default rootId (parentId) of null to render all the root level tree items/routes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When routing , component is not rendering in Side page
Issue. Your Layout component looks to be designed to render the content as children , but in your App component you don't pass...
Read more >
react-md/layout
Renders the navigation tree for the Layout component that adds some reasonable defaults to work with navigation items. Functions. Configuration.
Read more >
Tree - Ant Design
Virtual scroll only render items in visible region. Thus not support auto width (like long title with horizontal scroll). What does disabled node...
Read more >
Navigation - Starbucks React Pattern Library
If accountNav is provided, the global nav will render distinct submenus in desktop and mobile viewports. This submenu is geared toward the starbucks.com ......
Read more >
Navbar - React-Bootstrap
Here's an example of all the sub-components included in a responsive ... While not required, you can wrap the Navbar in a <Container>...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found