Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Problem when using ListItem Material ui #150

Open
DidierBoivin opened this issue Jan 15, 2021 · 2 comments · May be fixed by #152
Open

Problem when using ListItem Material ui #150

DidierBoivin opened this issue Jan 15, 2021 · 2 comments · May be fixed by #152

Comments

@DidierBoivin
Copy link

DidierBoivin commented Jan 15, 2021

Hey,
I am using a ListItem button to access to routes defined
Here is my routes file
`const routes = {
'/': () => ,
'/search': () => ,
'/newcase': () => ,
'/agenda': () => ,

}
export default routes;The main file is

         {[{id: 'Agendas', url: '/agenda'},{id: 'Search', url: '/search'},{ id: 'NewCase', url: '/newcase'}].map((element, index) => ( 
          
            <ListItem button key={element.id} component={A} href={element.url}>
            <ListItemIcon>{ <InboxIcon /> }</ListItemIcon>
            <ListItemText primary={element.id} />
            
          </ListItem>
          
        ))}
      </List>`

I have this message
0.chunk.js:110570 Warning: Failed prop type: Invalid prop component supplied to ForwardRef(ButtonBase). Expected an element type that can hold a ref. Did you accidentally provide a plain function component instead?

Please help

@prageeth
Copy link

I'm having the same issue. I beleive the A component is missing the ForwardRef:

Please see the MaterialUI documentation: https://material-ui.com/guides/composition/#caveat-with-refs

Specifically, the definition of the A tag here (https://github.com/Paratron/hookrouter/blob/v1.2.3/src/Link.js#L51) should use a Forward Ref:
https://reactjs.org/docs/react-api.html#reactforwardref

export const A = React.forwardRef(
   (props, ref) => <a ref={ref} {...setLinkProps(props)} />
);

@prageeth
Copy link

@DidierBoivin I've fixed it in my fork for now, and I use it in my own project. You can install it directly via github:

npm install hookrouter@pureartisan/hookrouter#mui --save

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

Successfully merging a pull request may close this issue.

2 participants