Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import { default as App } prevents selecting elements inside App #6439

Closed
Rheeseyb opened this issue Oct 1, 2024 · 0 comments · Fixed by #6453
Closed

import { default as App } prevents selecting elements inside App #6439

Rheeseyb opened this issue Oct 1, 2024 · 0 comments · Fixed by #6453

Comments

@Rheeseyb
Copy link
Contributor

Rheeseyb commented Oct 1, 2024

It seems that Utopia doesn't properly support export default for components, so if we use

const App = ...

export default App

then using import {default as App} from or import App from will result App being treated as arbitrary JS, as seen in this project https://utopia.pizza/p/098edac2-rogue-asteroid/

Note that

function App() {...}
export default App

doesn't work, but

export default function App() {...}

does work.

liady added a commit that referenced this issue Oct 7, 2024
**Problem:**
Today we don't recognize when a default export is declared separately.
```ts
function App(){...}
export default App
```
this is not treated as a component when it's imported:

<video
src="https://github.com/user-attachments/assets/a52ce448-c324-44e9-bae1-9c64c3af21e5"></video>

**Fix:**
Use `isExportDefault` instead of a specific check for a function or a
class

**Manual Tests:**
I hereby swear that:

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Play mode

Fixes #6439
liady added a commit that referenced this issue Dec 13, 2024
**Problem:**
Today we don't recognize when a default export is declared separately.
```ts
function App(){...}
export default App
```
this is not treated as a component when it's imported:

<video
src="https://github.com/user-attachments/assets/a52ce448-c324-44e9-bae1-9c64c3af21e5"></video>

**Fix:**
Use `isExportDefault` instead of a specific check for a function or a
class

**Manual Tests:**
I hereby swear that:

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Play mode

Fixes #6439
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant