Closed Frankjunyulin closed 1 year ago
Hi @Frankjunyulin can you provide some of your _app.tsx code? From the error, it looks like maybe you were using a prop passed from the authenticator somewhere in the code. withAuthenticator
can send in props such as:
function App({ isPassedToWithAuthenticator, signOut, user })
@tannerabread here is my previous code in _app.tsx:
import React, {useEffect, useState} from "react";
import type {NextPage} from "next";
import Head from "next/head";
import ChatComponent from "./components/ChatComponent";
import Bot from "./Bot";
import Document from "./Document";
import Router from "next/router";
import {Auth} from "aws-amplify";
import MoonLoader from "react-spinners/MoonLoader";
import TransitionBar from "./components/TransitionBar";
import Playground from "./Playground";
import dynamic from "next/dynamic";
import {withAuthenticator} from "@aws-amplify/ui-react";
/*
const DearWidget = dynamic(() => import("./components/DearWidget"), {
ssr: false,
});
*/
type MainComponentProps = {
status: String;
setTransitionStatus: (val: String) => void;
};
function MainComponent({status, setTransitionStatus}: MainComponentProps) {
if (status === "Bot") {
return <Bot setTransitionStatus={setTransitionStatus} />;
} else if (status === "Playground") {
return <Playground setTransitionStatus={setTransitionStatus} />;
} else {
return <Document setTransitionStatus={setTransitionStatus} />;
}
}
const Home: NextPage = () => {
const [isSpinned, setIsSpinned] = useState(true);
const [transitionStatus, setTransitionStatus] = useState<String>("Bot");
const [userName, setUserName] = useState<String>("");
const [userEmail, setUserEmail] = useState<String>("");
useEffect(() => {
const crrentUser = getUserInfo();
console.log(crrentUser);
}, []);
const getUserInfo = async () => {
const crrentUser = await Auth.currentUserInfo()
.then((userInfo) => {
console.log("user");
console.log(userInfo);
setUserName(userInfo.username);
setUserEmail(userInfo.attributes.email);
/*
Router.push({
pathname: "/Bot",
query: {
username: userInfo.username,
email: userInfo.attributes.email,
},
});
*/
})
.finally(() => {
setIsSpinned(false);
});
return crrentUser;
};
console.log();
if (isSpinned === true) {
return (
<div className="flex h-screen items-center justify-center">
<MoonLoader color="#36d7b7" />
</div>
);
}
return (
<div>
<Head>
<title>Dear.ai</title>
<meta name="description" content="AI and Cloud Platform" />
<link rel="icon" href="/favicon.ico" />
</Head>
{/*<Procedures />*}
{/*<ChatComponent />*/}
<div className="flex flex-row h-screen">
<TransitionBar
status={transitionStatus}
setStatus={setTransitionStatus}
userName={userName}
userEmail={userEmail}
/>
<MainComponent
status={transitionStatus}
setTransitionStatus={setTransitionStatus}
/>
</div>
</div>
);
};
export default withAuthenticator(Home);
It throws error while I changed the last line:
export default withAuthenticator(Home);
to
export default Home;
I don't see any problems in your _app.tsx
directly, but is it possible that something you were passing to the /components/BotConfirm
was related to or depended on withAuthenticator
or something else from amplify auth?
Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and are in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you.
Thank you!
Before opening, please confirm:
JavaScript Framework
React, Next.js
Amplify APIs
Authentication
Amplify Categories
No response
Environment information
Describe the bug
Cannot remove withAuthenticator in my _app.tsx file. Otherwise it would give the error while I run
npm run build
:Expected behavior
npm run build
succeedReproduction steps
export default withAuthenticator(MyApp);
toexport default MyApp;
in_app.tsx
Code Snippet
Log output
aws-exports.js
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response