Weird React problem

the homepage of my game looks like this:

the cool buttons on it use this component:

i wanted to use the same button in the New Island page:

but, for some reason, the page renders the ENTIRE menu page, rather than just the button i specifically imported.

can anyone explain and/or help with this?

I think this has to do with how you export CoolBtn from home.jsx, particularly in that you’re not exporting it.

maybe this page can help

it says:

the default export can be imported with any name. For example:

// file test.js
const k = 12;
export default k;
// some other file
import m from "./test"; // note that we have the freedom to use import m instead of import k, because k was default export
console.log(m); // 12

which looks like what’s happening here. you have an export default for the “entire menu page,” and you import it under a different name CoolBtn

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.