I’m new to @material-tailwind/react
I want to use Drawer
in my ongoing create-react-app project.
I followed this guide.
But I got this error:
Cannot read properties of null (reading 'useRef')
TypeError: Cannot read properties of null (reading 'useRef')
Any advice would be appreciated.
Thank you.
I created a new project for testing according to this guide.
In tailwind.config.js
:
import withMT from "@material-tailwind/react/utils/withMT";
module.exports = withMT({
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
});
In index.jsx
:
...
import {ThemeProvider} from '@material-tailwind/react'
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<ThemeProvider>
<App />
</ThemeProvider>
</React.StrictMode>
);
In App.jsx
:
import { Drawer, Button } from "@material-tailwind/react";
export default function App() {
const [open, setOpen] = useState(false);
return (
<>
<Button onClick={() => setOpen(true)}>Open Drawer</Button>
<Drawer open={open} onClose={() => setOpen(false)}>
<h1>Drawer Content</h1>
</Drawer>
</>
)
}
And got the error above.