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

React: Refs and Memoization - Code Sandbox Embed Displays Wrong File #26719

Closed
2 tasks done
columk1 opened this issue Nov 11, 2023 · 3 comments
Closed
2 tasks done

React: Refs and Memoization - Code Sandbox Embed Displays Wrong File #26719

columk1 opened this issue Nov 11, 2023 · 3 comments

Comments

@columk1
Copy link
Contributor

columk1 commented Nov 11, 2023

Describe your suggestion

Issue

The file that appears in the embedded Code Sandbox editor is index.js, which doesn't exist. It is open by default in the editor tab and and an error is displayed.

Screenshot 2023-11-10 at 1 57 10 PM

Suggestion

This should be changed to main.jsx in the embed settings. I think this is possible because the Code Sandbox in the fetching lesson doesn't have this issue. It displays the correct file Profile.jsx by default:

https://www.theodinproject.com/lessons/node-path-react-new-fetching-data-in-react

I believe a query is missing from the url (something like ?file=main.jsx&embed=1). There are some extra characters in the fetch sandbox url so I'm not sure if I can work on the issue without access to wherever these queries are generated.

Path

Node / JS

Lesson Url

https://www.theodinproject.com/lessons/node-path-react-new-refs-and-memoization

Checks

(Optional) Discord Name

columk

(Optional) Additional Comments

No response

@Asartea
Copy link
Contributor

Asartea commented Nov 11, 2023

There are some extra characters in the fetch sandbox url so I'm not sure if I can work on the issue without access to wherever these queries are generated.

Assuming you mean this part: ?embed=1&file=%2Fsrc%2FProfile.jsx%3A1%2C1 (from Fetching Data in React), those are just URLEncoded, and translate to ?embed=1&file=/src/Profile.jsx:1,1

Playing around for it with a bit that last part seems to be in the format: ?file=<full path to file>:<line number to start on>,<character in that line to start on>

@columk1
Copy link
Contributor Author

columk1 commented Nov 11, 2023

Thanks for that, I understand now and was able to get it working.

This change will fix it:
- ?embed=1
+ ?file=%2Fsrc%2FApp.jsx&embed=1

@columk1
Copy link
Contributor Author

columk1 commented Nov 21, 2023

Update

It looks like CodeSandbox have changed their logic as the default view is completely different now.

It renders the right file (App.jsx) now which makes the output correct, but it defaults to package-lock.json in the editor, and now the explorer is hidden so finding the code that is relevant to the lesson is not very intuitive and involves some clicking around.

I think this is a new issue and I don't think it can be solved with url encoding. The codesandbox cloud embedding is still in beta and is missing some customization features.

@columk1 columk1 closed this as completed Dec 18, 2023
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

No branches or pull requests

2 participants