Инициализация open status
с useEffect будет работать
const [open, setOpen] = useState(false);
useEffect(() => {
setOpen(true);
}, []);
<Popper
open={open}
...
/>
Полный код:
import React, { useEffect, useState, useRef } from "react";
import Popper from "@material-ui/core/Popper";
import Typography from "@material-ui/core/Typography";
import Button from "@material-ui/core/Button";
import Fade from "@material-ui/core/Fade";
import Paper from "@material-ui/core/Paper";
export default function PositionedPopper() {
const elRef = useRef(null);
const [open, setOpen] = useState(false);
useEffect(() => {
setOpen(true);
}, []);
return (
<div>
<Popper
open={open}
anchorEl={elRef.current}
placement={"left"}
transition
>
{({ TransitionProps }) => (
<Fade {...TransitionProps} timeout={350}>
<Paper>
<Typography>The content of the Popper.</Typography>
</Paper>
</Fade>
)}
</Popper>
<Button ref={elRef}>left</Button>
</div>
);
}