GeethikaG
Reactiflux3y ago
12 replies
Geethika

Server ErrorError: Element type is invalid: expected a string (for built-in components)...

I am getting this error in console and also when I go to the page personal-info in my next.js project! --->

Server Error
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

I am trying to route to personal-info page from sign up page.

Code snippets:

>> Function that handles what happens after recieveing sign up OTP ,

const handleOtp = async (otpNumber, phoneNumber,userPassword) => {
    try {
      setLoading(true);
      ....
      if (error) throw error;
      else {
        alert("Welcome!");
        router.push('/personal-info')
      }
    ...
 } catch (error) {
      //console.log(phoneNumber, otpNumber,userPassword);
      alert(error.error_description || error.message);
    } finally {
      setLoading(false);
    }
  };


>> Personal info page code

import PersonalDetails from "../components/PersonalDetails"

 const PersonalInfo = () => {

    return (
        <>
        <PersonalDetails/>
        </>
        
    )
}


export default PersonalInfo

>> Personal details page code snippets

...
 const goToHomePage = () => {

        router.push('/')
    }
...
  <Button size="lg"

                                className="button block"
                                onClick={goToHomePage}
                            >
                                <span>Save</span>
                            </Button>
...
Was this page helpful?