Skip to content

Comment to help user understand 'mountNode' on home page example. #1019

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

Closed
wants to merge 7 commits into from

Conversation

craigdanj
Copy link

#1017
This is to help users understand the mountNode variable on the home page of reactjs.org sicne currently it offers no explanation. This lack of an explanation might confuse users.

eg: https://stackoverflow.com/questions/23600443/uncaught-referenceerror-mountnode-is-not-defined

This is to help users understand the mountNode variable on the home page of reactjs.org sicne currently it offers no explanation. This lack of an explanation might confuse users. 


eg: https://stackoverflow.com/questions/23600443/uncaught-referenceerror-mountnode-is-not-defined
@facebook-github-bot
Copy link
Collaborator

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@craigdanj craigdanj changed the title Comment to help user understand 'm'ountNode' on home page example. Comment to help user understand 'mountNode' on home page example. Jun 28, 2018
@reactjs-bot
Copy link

reactjs-bot commented Jun 28, 2018

Deploy preview for reactjs ready!

Built with commit 5b4daa3

https://deploy-preview-1019--reactjs.netlify.com

@facebook-github-bot
Copy link
Collaborator

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@alexkrolick
Copy link
Collaborator

This is a good change, but the formatting in the front page code blocks is very narrow. Can you look at the deploy preview and figure out how to wrap the comment so it fits?

Thanks!

Copy link
Member

@gaearon gaearon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I'm not sure this is very helpful.

screen shot 2018-08-03 at 6 56 19 pm

Formatting isn't the only issue. We only have so much we can tell in these examples. If this single line is worth a lengthy explanation, why aren't other lines also worth it? Why are we over-explaining this particular line in this particular example?

I don't think this solution is good. Maybe instead we can rename mountNode to something more meaningful. Or maybe it should be something like

document.getElementById('first-example')

which is self-explanatory.

@alexkrolick
Copy link
Collaborator

Maybe we could pull the react-dom part into the home page examples plugin? Mountnode is defined there and needed to make the examples work with live edits.

@craigdanj
Copy link
Author

@gaearon I actually like your idea better than mine. I agree mine isn't the best solution.

Can we replace 'mountNode' with

document.getElementById('root')

In all the examples? Would that make sense?

@gaearon
Copy link
Member

gaearon commented Aug 3, 2018

I think it will be confusing to have root in several examples since IDs are supposed to be unique. But if you give each container a different ID (e.g. simple-component, todo-app, etc) then it will make sense.

This is as per @Gearon 's suggestion in the comments.
@craigdanj
Copy link
Author

craigdanj commented Aug 3, 2018

@gaearon I've updated the first example to use first-example. I figured if I add simple-component it'll look like I'm rendering the helloWorld component to simple-component when it actually is itself the simple component. Let me know what you think.

I can change the other examples if this is fine.

@craigdanj
Copy link
Author

craigdanj commented Aug 14, 2018

@gaearon So I've updated all the examples to use getElementById() and have used ids that correspond to each example's title (like you suggested) since this makes more sense for the documentation.

Do let me know if the naming is appropriate and if there is anything else I need to change since the main website has live code editing.

alexkrolick added a commit that referenced this pull request Jan 2, 2019
This is still a bit opaque but it's difficult to fix with the current way
CodeEditor works:
- long-term CodeEditor.js could take a node reference instead of defining
  mountNode internally
- could also use document.createElement to define the target in the code,
  but this could be mislead people to think this is required instead of
  using an existing reference

see #1017, #1018, #1019
@gaearon
Copy link
Member

gaearon commented Jan 2, 2019

I did something similar in #1526. I couldn't merge this PR because it didn't actually work, but thanks for starting it!

@gaearon gaearon closed this Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants