MCPcopy Create free account
hub / github.com/callstack/react-native-paper / PortalManager

Class PortalManager

src/components/Portal/PortalManager.tsx:14–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12 * Portal host is the component which actually renders all Portals.
13 */
14export default class PortalManager extends React.PureComponent<{}, State> {
15 state: State = {
16 portals: [],
17 };
18
19 mount = (key: number, children: React.ReactNode) => {
20 this.setState((state) => ({
21 portals: [...state.portals, { key, children }],
22 }));
23 };
24
25 update = (key: number, children: React.ReactNode) =>
26 this.setState((state) => ({
27 portals: state.portals.map((item) => {
28 if (item.key === key) {
29 return { ...item, children };
30 }
31 return item;
32 }),
33 }));
34
35 unmount = (key: number) =>
36 this.setState((state) => ({
37 portals: state.portals.filter((item) => item.key !== key),
38 }));
39
40 render() {
41 return this.state.portals.map(({ key, children }) => (
42 <View
43 key={key}
44 collapsable={
45 false /* Need collapsable=false here to clip the elevations, otherwise they appear above sibling components */
46 }
47 pointerEvents="box-none"
48 style={StyleSheet.absoluteFill}
49 >
50 {children}
51 </View>
52 ));
53 }
54}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…