@fruits-chain/react-native-xiaoshu
Version:
🌈 React Native UI library
37 lines (33 loc) • 1.18 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("react");
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
class PortalConsumer extends _react.Component {
componentDidMount() {
this.checkManager();
// // Delay updating to prevent React from going to infinite loop
// await Promise.resolve()
this.key = this.props.manager.mount(this.props.children);
}
componentDidUpdate() {
this.checkManager();
this.props.manager.update(this.key, this.props.children);
}
componentWillUnmount() {
this.checkManager();
this.props.manager.unmount(this.key);
}
render() {
return null;
}
checkManager() {
if (!this.props.manager) {
throw new Error('Looks like you forgot to wrap your root component with `Provider` component from `@fruits-chain/react-native-xiaoshu`.\n\n' + "Please read our getting-started guide and make sure you've followed all the required steps.\n\n" + 'https://24jieqi.github.io/xiaoshu-doc/component/basic/portal');
}
}
}
exports.default = PortalConsumer;
//# sourceMappingURL=portal-consumer.js.map
;