Hello, I have a problem importing my React component into the App.
I’ve already tried the import method and now I’m trying the require method, both without success.
What would be the correct method?
Here’s an example of my code:
const { HeaderPicker } = require("./HeaderPicker");
function App() {
return (
<div>
<h1>Welcome</h1>
<Theme theme="spectrum" scale="medium" color="light">
<Menu selects="single">
<MenuItem selected>Sample Menu</MenuItem>
<HeaderPicker/>
<MenuDivider></MenuDivider>
<MenuItem>Select Option 1</MenuItem>
<MenuItem>Select Option 2</MenuItem>
<MenuItem>Select Option 3</MenuItem>
<MenuItem>Select Option 4</MenuItem>
<MenuItem disabled>Disabled Option</MenuItem>
</Menu>
</Theme>
</div>
);
}
export default App;
function HeaderPicker() {
return (
<>
<sp-field-group>
<div>
<Picker theme="dark" id="picker-s" size="s" label="Selection type">
<sp-menu-item id="sb-header">SB Header</sp-menu-item>
<sp-menu-item id="con-header">Con Header</sp-menu-item>
<sp-menu-divider></sp-menu-divider>
<sp-menu-item id="aw-header">Alienware Header</sp-menu-item>
<sp-menu-item id="gaming-header">Gaming Header</sp-menu-item>
<sp-menu-divider></sp-menu-divider>
<sp-menu-item id="outlet-header">Outlet Header</sp-menu-item>
<sp-menu-item id="experts-header">Experts Header</sp-menu-item>
</Picker>
</div>
</sp-field-group>
</>
);
}
module.exports = { HeaderPicker };
This is the error that keeps appearing on my console. The same error for both component import methods.
uxp://uxp-internal/domjs_scripts.js:2 Uncaught Error: Module not found: "./HeaderPicker". Parent module folder was: "./".
I’m using the UXP 7.3 on PSD 25.2.0.