Skip to content

Commit 0dfaf2d

Browse files
committed
Update docs
1 parent 94ea29f commit 0dfaf2d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Create a portal node, populate it with `InPortal`, and use it somewhere with `Ou
4343
import * as portals from 'react-reverse-portal';
4444

4545
const MyComponent = (props) => {
46-
const portalNode = React.useMemo(() => portals.createPortalNode(), []);
46+
const portalNode = React.useMemo(() => portals.createHtmlPortalNode(), []);
4747

4848
return <div>
4949
{/*
@@ -104,11 +104,17 @@ Normally in `ComponentA`/`ComponentB` examples like the above, switching from `C
104104

105105
How does it work under the hood?
106106

107-
### `portals.createPortalNode`
107+
### `portals.createHtmlPortalNode`
108108

109109
This creates a detached DOM node, with a little extra functionality attached to allow transmitting props later on.
110110

111-
This node will contain your portal contents later, and eventually be attached in the target location. By default it's a `div`, but you can pass your tag of choice (as a string) to override this if necessary. It's a plain DOM node, so you can mutate it to set any required props (e.g. `className`) with the standard DOM APIs.
111+
This node will contain your portal contents later, within a `<div>`, and will eventually be attached in the target location. Its plain DOM node is available at `.element`, so you can mutate that to set any required props (e.g. `className`) with the standard DOM APIs.
112+
113+
### `portals.createSvgPortalNode`
114+
115+
This creates a detached SVG DOM node. It works identically to the node from `createHtmlPortalNode`, except it will work with SVG elements. Content is placed within a `<g>` instead of a `<div>`.
116+
117+
An error will be thrown if you attempt to use a HTML node for SVG content, or a SVG node for HTML content, because browsers do not support this.
112118

113119
### `portals.InPortal`
114120

0 commit comments

Comments
 (0)