Error: The default export is not a React Component in page: "/"
Answered
Chestnut-backed Chickadee posted this in #help-forum
Chestnut-backed ChickadeeOP
Hello everyone im learing next.js to work with my react app so i make this code from dosc and videos on youtube
page.js
test.jsx
err Error: The default export is not a React Component in page: "/"
page.js
import Image from "next/image";
import styles from "./page.module.css";
import { Router } from "next/navigation";
import { Test } from './test.jsx'
const App = () => {
return (
<Router>
<Router>
<Router path= '/' element ={Test}/>
</Router>
</Router>
)
}test.jsx
// Test.jsx
import React from 'react';
const Test = () => {
return (
<h1>Hello World</h1>
);
};
export default Test;err Error: The default export is not a React Component in page: "/"
Answered by English Spot
have you make your route?
https://nextjs.org/docs/app/building-your-application/routing/defining-routes
https://nextjs.org/docs/app/building-your-application/routing/defining-routes
17 Replies
Chestnut-backed ChickadeeOP
and thanks for everyone
@Chestnut-backed Chickadee Hello everyone im learing next.js to work with my react app so i make this code from dosc and videos on youtube
page.js
js
import Image from "next/image";
import styles from "./page.module.css";
import { Router } from "next/navigation";
import { Test } from './test.jsx'
const App = () => {
return (
<Router>
<Router>
<Router path= '/' element ={Test}/>
</Router>
</Router>
)
}
test.jsx
jsx
// Test.jsx
import React from 'react';
const Test = () => {
return (
<h1>Hello World</h1>
);
};
export default Test;
err Error: The default export is not a React Component in page: "/"
you can drop the curly brackets around the
Test, and the .jsx extension, from your import statementYou use curly brackets for importing explicitly
import Test from './test'English Spot
^ this one
or you can change it to this
// Test.jsx
import React from 'react';
const Test = () => {
return (
<h1>Hello World</h1>
);
};
export { Test };or you can change it to this
files be like
import Image from "next/image";
import styles from "./page.module.css";
import { Router } from "next/navigation";
import { Test } from './test'
const App = () => {
return (
<Router>
<Router>
<Router path= '/' element ={Test}/>
</Router>
</Router>
)
}// Test.jsx
import React from 'react';
const Test = () => {
return (
<h1>Hello World</h1>
);
};
export { Test };?
its give me same err
English Spot
import styles from "./page.module.css";
import { Test } from './test'
const App = () => {
return (
<Test/>
)
}
export default Appi dont think you use <Router/>
@English Spot js
import styles from "./page.module.css";
import { Test } from './test'
const App = () => {
return (
<Test/>
)
}
export default App
Chestnut-backed ChickadeeOP
its works but what if i go to
localhost:3000/help
localhost:3000/help
This page could not be found.
how i can make a page with this url
like react
patch and element
patch and element
English Spot
have you make your route?
https://nextjs.org/docs/app/building-your-application/routing/defining-routes
https://nextjs.org/docs/app/building-your-application/routing/defining-routes
Answer