@alfalab/core-components-portal
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -10,4 +10,8 @@ /// <reference types="react" /> | ||
getPortalContainer?: () => Element; | ||
/** | ||
* Немедленно отрендерить дочерние элементы (false - контент будет отрендерен на след. рендер). | ||
*/ | ||
immediateMount?: boolean; | ||
}; | ||
declare const Portal: import("react").ForwardRefExoticComponent<PortalProps & import("react").RefAttributes<Element>>; | ||
export { PortalProps, Portal }; |
@@ -10,4 +10,6 @@ 'use strict'; | ||
var Portal = react.forwardRef(function (_a, ref) { | ||
var _b = _a.getPortalContainer, getPortalContainer = _b === void 0 ? utils.getDefaultPortalContainer : _b, children = _a.children; | ||
var _c = react.useState(null), mountNode = _c[0], setMountNode = _c[1]; | ||
var _b = _a.getPortalContainer, getPortalContainer = _b === void 0 ? utils.getDefaultPortalContainer : _b, _c = _a.immediateMount, immediateMount = _c === void 0 ? false : _c, children = _a.children; | ||
var _d = react.useState(function () { | ||
return immediateMount ? getPortalContainer() : null; | ||
}), mountNode = _d[0], setMountNode = _d[1]; | ||
react.useEffect(function () { | ||
@@ -14,0 +16,0 @@ setMountNode(getPortalContainer()); |
@@ -10,4 +10,8 @@ /// <reference types="react" /> | ||
getPortalContainer?: () => Element; | ||
/** | ||
* Немедленно отрендерить дочерние элементы (false - контент будет отрендерен на след. рендер). | ||
*/ | ||
immediateMount?: boolean; | ||
}; | ||
declare const Portal: import("react").ForwardRefExoticComponent<PortalProps & import("react").RefAttributes<Element>>; | ||
export { PortalProps, Portal }; |
@@ -10,4 +10,6 @@ 'use strict'; | ||
var Portal = react.forwardRef(function (_a, ref) { | ||
var _b = _a.getPortalContainer, getPortalContainer = _b === void 0 ? utils.getDefaultPortalContainer : _b, children = _a.children; | ||
var _c = react.useState(null), mountNode = _c[0], setMountNode = _c[1]; | ||
var _b = _a.getPortalContainer, getPortalContainer = _b === void 0 ? utils.getDefaultPortalContainer : _b, _c = _a.immediateMount, immediateMount = _c === void 0 ? false : _c, children = _a.children; | ||
var _d = react.useState(function () { | ||
return immediateMount ? getPortalContainer() : null; | ||
}), mountNode = _d[0], setMountNode = _d[1]; | ||
react.useEffect(function () { | ||
@@ -14,0 +16,0 @@ setMountNode(getPortalContainer()); |
@@ -10,4 +10,8 @@ /// <reference types="react" /> | ||
getPortalContainer?: () => Element; | ||
/** | ||
* Немедленно отрендерить дочерние элементы (false - контент будет отрендерен на след. рендер). | ||
*/ | ||
immediateMount?: boolean; | ||
}; | ||
declare const Portal: import("react").ForwardRefExoticComponent<PortalProps & import("react").RefAttributes<Element>>; | ||
export { PortalProps, Portal }; |
@@ -6,4 +6,6 @@ import { forwardRef, useState, useEffect } from 'react'; | ||
var Portal = forwardRef(function (_a, ref) { | ||
var _b = _a.getPortalContainer, getPortalContainer = _b === void 0 ? getDefaultPortalContainer : _b, children = _a.children; | ||
var _c = useState(null), mountNode = _c[0], setMountNode = _c[1]; | ||
var _b = _a.getPortalContainer, getPortalContainer = _b === void 0 ? getDefaultPortalContainer : _b, _c = _a.immediateMount, immediateMount = _c === void 0 ? false : _c, children = _a.children; | ||
var _d = useState(function () { | ||
return immediateMount ? getPortalContainer() : null; | ||
}), mountNode = _d[0], setMountNode = _d[1]; | ||
useEffect(function () { | ||
@@ -10,0 +12,0 @@ setMountNode(getPortalContainer()); |
@@ -10,4 +10,8 @@ /// <reference types="react" /> | ||
getPortalContainer?: () => Element; | ||
/** | ||
* Немедленно отрендерить дочерние элементы (false - контент будет отрендерен на след. рендер). | ||
*/ | ||
immediateMount?: boolean; | ||
}; | ||
declare const Portal: import("react").ForwardRefExoticComponent<PortalProps & import("react").RefAttributes<Element>>; | ||
export { PortalProps, Portal }; |
@@ -5,4 +5,4 @@ import { forwardRef, useState, useEffect } from 'react'; | ||
const Portal = forwardRef(({ getPortalContainer = getDefaultPortalContainer, children }, ref) => { | ||
const [mountNode, setMountNode] = useState(null); | ||
const Portal = forwardRef(({ getPortalContainer = getDefaultPortalContainer, immediateMount = false, children }, ref) => { | ||
const [mountNode, setMountNode] = useState(() => immediateMount ? getPortalContainer() : null); | ||
useEffect(() => { | ||
@@ -9,0 +9,0 @@ setMountNode(getPortalContainer()); |
{ | ||
"name": "@alfalab/core-components-portal", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Portal component", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected potential security risk
Supply chain riskAI has determined that this package may contain potential security issues or vulnerabilities.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Telemetry
Supply chain riskThis package contains telemetry which tracks how it is used.
Found 1 instance in 1 package
15078
358
1
2