You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when im trying to use Drawer in next.js 15. it's saying Error: @fluentui/react-motion: Invalid child element. Motion factories require a single child element to be passed. That element element should support ref forwarding i.e. it should be either an intrinsic element (e.g. div) or a component that uses React.forwardRef().
Expected Behavior
it's should work.
Reproduction
don't have the link
Steps to reproduce
Install next.js 15.
Use the fluent ui 9 latest version
and try to use the drawer
Are you reporting an Accessibility issue?
None
Suggested severity
Urgent - No workaround and Products/sites are affected
Products/sites affected
No response
Are you willing to submit a PR to fix?
yes
Validations
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
The provided reproduction is a minimal reproducible example of the bug.
This is how I workaround this (dirty hack). Basically I had to replace getChildElement.js with my patched version.
in package.json I added this script: "postinstall": "cp src/tools/getChildElement.js node_modules/@fluentui/react-motion/lib/utils/getChildElement.js"
src/tools/getChildElement.js:
import * as React from "react";
import * as ReactIs from "react-is";
export function getChildElement(children) {
try {
const child = React.Children.only(children);
if (
typeof child.type === "string" ||
ReactIs.isForwardRef({
...child,
/**
* Patch type because of issues with Next.js
* https://github.com/microsoft/fluentui/issues/33404
*/
["$$typeof"]:
child["$$typeof"] === Symbol.for("react.transitional.element") ? Symbol.for("react.element") : child["$$typeof"],
})
) {
return child;
}
// We don't need to do anything here: we catch the exception from React to throw a more meaningful error
// eslint-disable-next-line no-empty
} catch {}
throw new Error(
[
"@fluentui/react-motion: Invalid child element.",
"\n",
"Motion factories require a single child element to be passed. ",
"That element element should support ref forwarding i.e. it should be either an intrinsic element (e.g. div) or a component that uses React.forwardRef().",
].join(""),
);
}
Reacted by Andrew Koltyakov, Tibor Takacs, ultrababs, Christian Rapelius-Saar and vvbbnn00
Andrew Koltyakov (@koltyakov) , I was just triaging the issue to get it into the correct backlog so no further updates from me 🙂. Given the season I wouldn't expect anyone to pick this up before January.
I encountered this issue with the OverlayDrawer and the Drawer when using the overlay type with React 19. Switching the same drawer to the inline type works as expected.
Finally downgraded to React 18 and the overlay worked as expected.
Activity
spmonahan commentedon Dec 4, 2024
Anish Kumar (@anishkumar127) Please provide a repro link so I can take a look.
StackBlitz is a good way to set this up.
anishkumar127 commentedon Dec 5, 2024
Link: https://stackblitz.com/edit/stackblitz-starters-m3ccwj?description=The%20React%20framework%20for%20production&file=next%2Fpackage.json&title=Next.js%20Starter
even now i'm not able to install
npm install @fluentui/react-componentswith the next.js 15 it's saying this on terminal.spmonahan commentedon Dec 5, 2024
This is because
react-componentsdoes not currently support React 19. See: https://github.com/microsoft/fluentui/blob/master/packages/react-components/react-components/package.json#L82React 19 will be supported in the future.
Tudor Popa (@tudorpopams) and Dmytro Kirpa (@dmytrokirpa) for visibility.
vlad-ivanov-d commentedon Dec 14, 2024
Sean Monahan (@spmonahan) it doesn't work even with React 18 and Next.js 15. So this issue is not related to React 19.
The problem is in
isForwardReffunc right here:fluentui/packages/react-components/react-motion/library/src/utils/getChildElement.ts
Line 8 in b5d571f
All components are
Symbol(react.transitional.element)in Next.js (I guess because of SSR stuff). That's why this check always fails.vlad-ivanov-d commentedon Dec 17, 2024
This is how I workaround this (dirty hack). Basically I had to replace
getChildElement.jswith my patched version.in package.json I added this script:
"postinstall": "cp src/tools/getChildElement.js node_modules/@fluentui/react-motion/lib/utils/getChildElement.js"src/tools/getChildElement.js:
koltyakov commentedon Dec 19, 2024
Sean Monahan (@spmonahan) any update on this? Did you guys manage to check the possible solution?
Next.js and SSR are the hot topic. It would be great seeing Fluent UI compatible with the top notch technologies.
spmonahan commentedon Dec 19, 2024
Andrew Koltyakov (@koltyakov) , I was just triaging the issue to get it into the correct backlog so no further updates from me 🙂. Given the season I wouldn't expect anyone to pick this up before January.
it950 commentedon Jan 4, 2025
In React Router v7, the error still exists when a component use Drawer:

wnbittle commentedon Jan 6, 2025
I have the same problem. The work around above didn't work for me since I'm using
pnpm, but this did:rlamtabbet commentedon Feb 14, 2025
I encountered this issue with the OverlayDrawer and the Drawer when using the overlay type with React 19. Switching the same drawer to the inline type works as expected.
Finally downgraded to React 18 and the overlay worked as expected.
ellorenz2 commentedon Mar 4, 2025
Using Visual Studio 2022 and React 19
\node_modules@fluentui\react-motion\lib\factories\createPresenceComponent.js:19:35
node_modules@fluentui\react-context-selector\lib\createContext.js:7:45)
react-dialog\lib\components\Dialog\Dialog.js:12:19)
node_modules@fluentui\react-drawer\lib\components\OverlayDrawer\OverlayDrawer.js:10:19)
TextDirectionProvider
packages\react\src\TextDirectionContext.tsx:21:79)
at FluentProvider (https//../node_modules/.vite/deps/@fluentui_react-components.js?v=6e8f36c8:12170:17) {name: 'Error Component Stack', stack: 'Error Component Stack:
at Object.assign (…ntui_react-components.js?v=6e8f36c8:12170:17)', message: ''}
boldbaatar-dx commentedon Mar 10, 2025
Is there any solution for this?
ropre4 commentedon Mar 11, 2025
I ran into this issue with NextJS 15, React 19, with "Dialog" react-component.
I must say, big THANK YOU to Vlad Ivanov (@vlad-ivanov-d) , as his hack is still the only soution to this