Skip to content

Commit

Permalink
fix:Ripple and Tabview bugs in Next.js App Router (#5674)
Browse files Browse the repository at this point in the history
* fix:Ripple and Tabview bugs in next.js >= 13

* #5675 Theme update for OrderList

* fix: Remove unnecessary code

* Update comment

* fix: break Ripple when use Page Router

---------

Co-authored-by: Yiğit FINDIKLI <[email protected]>
  • Loading branch information
kl-nevermore and yigitfindikli authored Jan 3, 2024
1 parent a82e965 commit c7fe6c9
Show file tree
Hide file tree
Showing 58 changed files with 39,912 additions and 28,301 deletions.
10 changes: 8 additions & 2 deletions components/lib/ripple/Ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { RippleBase } from './RippleBase';

export const Ripple = React.memo(
React.forwardRef((inProps, ref) => {
const [isMounted, setMounted] = React.useState(false);
const inkRef = React.useRef(null);
const targetRef = React.useRef(null);
const context = React.useContext(PrimeReactContext);
Expand Down Expand Up @@ -78,12 +79,17 @@ export const Ripple = React.memo(
}));

useMountEffect(() => {
if (inkRef.current) {
// for App Router in Next.js ^14
setMounted(true);
});

useUpdateEffect(() => {
if (isMounted && inkRef.current) {
targetRef.current = getTarget();
setDimensions();
bindEvents();
}
});
}, [isMounted]);

useUpdateEffect(() => {
if (inkRef.current && !targetRef.current) {
Expand Down
8 changes: 7 additions & 1 deletion components/lib/utils/ObjectUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ export default class ObjectUtils {
static isValidChild(child, type, validTypes) {
/* eslint-disable */
if (child) {
const childType = this.getComponentProp(child, '__TYPE') || (child.type ? child.type.displayName : undefined);
let childType = this.getComponentProp(child, '__TYPE') || (child.type ? child.type.displayName : undefined);

// for App Router in Next.js ^14,
if (!childType && child?.type?._payload?.value) {
childType = child.type._payload.value.find((v) => v === type);
}

const isValid = childType === type;

try {
Expand Down
Loading

0 comments on commit c7fe6c9

Please sign in to comment.