Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: useSidebarItemContext should be used within the SidebarItemContext provider! #299

Closed
valerius21 opened this issue Jul 14, 2022 · 3 comments
Labels
needs info Further information is requested

Comments

@valerius21
Copy link

Describe the bug
I'm getting the in the title mentioned error while using the example code. Browsing the code, it looks alright to me.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new component
  2. use the following code
import { Sidebar } from 'flowbite-react'

const TemplateSidebarNavigation = () => {
  return (
    <div>
      <h2>{'TemplateSidebarNavigation'}</h2>
      <Sidebar aria-label="Test DB">
        <Sidebar.Items>
          <Sidebar.Item href="#">Dashboard</Sidebar.Item>
        </Sidebar.Items>
      </Sidebar>
    </div>
  )
}

export default TemplateSidebarNavigation
  1. See error

Expected behavior
The component should render without any errors.

Screenshots
image

System information:

  • Device: PC
  • Resolution: 1440p
  • OS: Windows 11
  • Browser: Chrome
  • Version: latest

Project information:

  • Tailwind: ^3.1.4
  • Flowbite: ^1.4.7
  • Flowbite React: ^0.1.3
  • Type: Redwoodjs with React 18.2.0
@ValTM
Copy link

ValTM commented Jul 18, 2022

You need the correct structure:

<Sidebar aria-label="sidebar">
  <Logo />
  <Sidebar.Items>
    <Sidebar.ItemGroup>
      <Sidebar.Item icon={Home} href="/">Dashboard</Sidebar.Item>
      <Sidebar.Item href="page2">Page 2</Sidebar.Item>
    </Sidebar.ItemGroup>
  </Sidebar.Items>
</Sidebar>

Without the Sidebar.ItemGroup it throws the same error.

@rluders rluders added 🐛 bug Something isn't working confirmed This bug was confirmed labels Jul 18, 2022
@rluders rluders added this to the v1.0.0 milestone Jul 18, 2022
@rluders rluders added invalid This doesn't seem right and removed 🐛 bug Something isn't working confirmed This bug was confirmed labels Jul 25, 2022
@rluders
Copy link
Collaborator

rluders commented Jul 25, 2022

@valerius21 can you confirm that the solution above works?

@rluders rluders added needs info Further information is requested and removed invalid This doesn't seem right labels Jul 25, 2022
@valerius21
Copy link
Author

@rluders Thank you for the response. I'll retry everything again when RedwoodJS finishes the React 18 upgrade officially. I did not see it initially. redwoodjs/redwood#4992

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info Further information is requested
Projects
Status: Done
Development

No branches or pull requests

3 participants