@td-design/react-native
Version:
react-native UI组件库
45 lines • 1.15 kB
JavaScript
import React from 'react';
import { StyleSheet, View } from 'react-native';
export default class PortalManager extends React.PureComponent {
state = {
portals: []
};
mount = (key, children) => {
this.setState(state => ({
portals: [...state.portals, {
key,
children
}]
}));
};
update = (key, children) => this.setState(state => ({
portals: state.portals.map(item => {
if (item.key === key) {
return {
...item,
children
};
}
return item;
})
}));
unmount = key => this.setState(state => ({
portals: state.portals.filter(item => item.key !== key)
}));
render() {
return this.state.portals.map(_ref => {
let {
key,
children
} = _ref;
return /*#__PURE__*/React.createElement(View, {
key: key
/* Need collapsable=false here to clip the elevations, otherwise they appear above sibling components */,
collapsable: false,
pointerEvents: "box-none",
style: StyleSheet.absoluteFill
}, children);
});
}
}
//# sourceMappingURL=PortalManager.js.map