Atif
Atif

Reputation: 942

Unable to use material-ui withStyles() with react-beautiful-dnd

I am able to reproduce the error in a sandbox. These are the errors I'm seeing:

Local:

Warning: Stateless function components cannot be given refs. Attempts to access this ref will fail.

Check the render method of `WithStyles(Card)`.
    in Card (created by WithStyles(Card))
    in WithStyles(Card) (at Todo.js:112)

Local and Sandbox:

Invariant failed: Cannot get draggable ref from drag handle

From my googling, it seems that I can't use withStyles since it's a stateless functional component. If that's the case, what's the alternative? I would like to continue using the benefits of the withStyle wrapper (which is injecting the mui theme and stylesheet into the component).

Please be aware that I simplified my code for the sandbox for the sake of clarity (I removed redux for example).

Upvotes: 0

Views: 788

Answers (1)

Atif
Atif

Reputation: 942

The solution is to wrap the Card component in a div. Here is the sandbox with a working solution

Upvotes: 2

Related Questions