-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Grouped-Menu-Example
- Loading branch information
Showing
98 changed files
with
1,477 additions
and
784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as React from 'react'; | ||
import Portal from '@mui/material/Portal'; | ||
import { Box } from '@mui/system'; | ||
|
||
export default function SimplePortal() { | ||
const [show, setShow] = React.useState(false); | ||
const container = React.useRef(null); | ||
|
||
const handleClick = () => { | ||
setShow(!show); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<button type="button" onClick={handleClick}> | ||
{show ? 'Unmount children' : 'Mount children'} | ||
</button> | ||
<Box sx={{ p: 1, my: 1, border: '1px solid' }}> | ||
It looks like I will render here. | ||
{show ? ( | ||
<Portal container={() => container.current}> | ||
<span>But I actually render here!</span> | ||
</Portal> | ||
) : null} | ||
</Box> | ||
<Box sx={{ p: 1, my: 1, border: '1px solid' }} ref={container} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as React from 'react'; | ||
import Portal from '@mui/material/Portal'; | ||
import { Box } from '@mui/system'; | ||
|
||
export default function SimplePortal() { | ||
const [show, setShow] = React.useState(false); | ||
const container = React.useRef(null); | ||
|
||
const handleClick = () => { | ||
setShow(!show); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<button type="button" onClick={handleClick}> | ||
{show ? 'Unmount children' : 'Mount children'} | ||
</button> | ||
<Box sx={{ p: 1, my: 1, border: '1px solid' }}> | ||
It looks like I will render here. | ||
{show ? ( | ||
<Portal container={() => container.current!}> | ||
<span>But I actually render here!</span> | ||
</Portal> | ||
) : null} | ||
</Box> | ||
<Box sx={{ p: 1, my: 1, border: '1px solid' }} ref={container} /> | ||
</div> | ||
); | ||
} |
12 changes: 12 additions & 0 deletions
12
docs/data/material/components/portal/SimplePortal.tsx.preview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<button type="button" onClick={handleClick}> | ||
{show ? 'Unmount children' : 'Mount children'} | ||
</button> | ||
<Box sx={{ p: 1, my: 1, border: '1px solid' }}> | ||
It looks like I will render here. | ||
{show ? ( | ||
<Portal container={() => container.current!}> | ||
<span>But I actually render here!</span> | ||
</Portal> | ||
) : null} | ||
</Box> | ||
<Box sx={{ p: 1, my: 1, border: '1px solid' }} ref={container} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.