rc-util
Advanced tools
Comparing version 5.19.3 to 5.19.4
@@ -1,2 +0,2 @@ | ||
import * as React from 'react'; | ||
import type * as React from 'react'; | ||
export declare type PortalRef = {}; | ||
@@ -3,0 +3,0 @@ export interface PortalProps { |
@@ -8,2 +8,3 @@ import { useRef, useEffect, forwardRef, useImperativeHandle } from 'react'; | ||
children = props.children; | ||
var parentRef = useRef(); | ||
var containerRef = useRef(); // Ref return nothing, only for wrapper check exist | ||
@@ -19,2 +20,3 @@ | ||
containerRef.current = getContainer(); | ||
parentRef.current = containerRef.current.parentNode; | ||
initRef.current = true; | ||
@@ -28,2 +30,9 @@ } // [Legacy] Used by `rc-trigger` | ||
useEffect(function () { | ||
// Restore container to original place | ||
// React 18 StrictMode will unmount first and mount back for effect test: | ||
// https://reactjs.org/blog/2022/03/29/react-v18.html#new-strict-mode-behaviors | ||
if (containerRef.current.parentNode === null && parentRef.current !== null) { | ||
parentRef.current.appendChild(containerRef.current); | ||
} | ||
return function () { | ||
@@ -30,0 +39,0 @@ var _containerRef$current, _containerRef$current2; |
@@ -1,2 +0,2 @@ | ||
import * as React from 'react'; | ||
import type * as React from 'react'; | ||
export declare type PortalRef = {}; | ||
@@ -3,0 +3,0 @@ export interface PortalProps { |
@@ -20,2 +20,3 @@ "use strict"; | ||
children = props.children; | ||
var parentRef = (0, _react.useRef)(); | ||
var containerRef = (0, _react.useRef)(); // Ref return nothing, only for wrapper check exist | ||
@@ -31,2 +32,3 @@ | ||
containerRef.current = getContainer(); | ||
parentRef.current = containerRef.current.parentNode; | ||
initRef.current = true; | ||
@@ -40,2 +42,9 @@ } // [Legacy] Used by `rc-trigger` | ||
(0, _react.useEffect)(function () { | ||
// Restore container to original place | ||
// React 18 StrictMode will unmount first and mount back for effect test: | ||
// https://reactjs.org/blog/2022/03/29/react-v18.html#new-strict-mode-behaviors | ||
if (containerRef.current.parentNode === null && parentRef.current !== null) { | ||
parentRef.current.appendChild(containerRef.current); | ||
} | ||
return function () { | ||
@@ -42,0 +51,0 @@ var _containerRef$current, _containerRef$current2; |
{ | ||
"name": "rc-util", | ||
"version": "5.19.3", | ||
"version": "5.19.4", | ||
"description": "Common Utils For React Component", | ||
@@ -32,3 +32,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/enzyme": "^3.10.5", | ||
"@testing-library/jest-dom": "^5.16.4", | ||
"@testing-library/react": "^13.0.0", | ||
"@types/jest": "^25.2.3", | ||
@@ -43,8 +44,7 @@ "@types/react": "^16.9.3", | ||
"cross-env": "^7.0.2", | ||
"enzyme": "^3.10.0", | ||
"eslint": "^6.6.0", | ||
"father": "^2.14.0", | ||
"np": "^6.2.3", | ||
"react": "^16.2.0", | ||
"react-dom": "^16.2.0", | ||
"react": "^18.0.0", | ||
"react-dom": "^18.0.0", | ||
"typescript": "^4.1.3" | ||
@@ -51,0 +51,0 @@ }, |
184328
5703