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

No idea how to use? #1

Open
leefsmp opened this issue Mar 18, 2020 · 1 comment
Open

No idea how to use? #1

leefsmp opened this issue Mar 18, 2020 · 1 comment

Comments

@leefsmp
Copy link

leefsmp commented Mar 18, 2020

Hi, could you add a more verbose example? I have no idea how to use this component in my app, here is my attempt but doesn't work:

const GridContainer = (props) => {
   return (
     <DndProvider backend={HTML5Backend}>
       <GridProvider items={props.items}>
         <GridContent {...props}/>
       </GridProvider>
     </DndProvider>
   )
}

export default withDndContext(GridContainer);

Thanks!

@headwindz
Copy link
Owner

headwindz commented Mar 23, 2020

hi @leefsmp . It's supposed to wrap the component down in the component tree where the components up the tree may have already used DndContext.

const _GridContent = withDndContext(GridContent)
const GridContainer = (props) => {
   return (
     <DndProvider backend={HTML5Backend}>
       <GridProvider items={props.items}>
         <_GridContent {...props}/> // parent component DndProvider has set up DnDContext
       </GridProvider>
     </DndProvider>
   )
}

export default GridContainer;

i.e. apply withDndContext HOC to the inner component rather than the outer component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants