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

Add inline comments to code snippets in Main Concepts #967

Open
6 of 17 tasks
JavaScriptErika opened this issue Jun 11, 2018 · 10 comments
Open
6 of 17 tasks

Add inline comments to code snippets in Main Concepts #967

JavaScriptErika opened this issue Jun 11, 2018 · 10 comments

Comments

@JavaScriptErika
Copy link

JavaScriptErika commented Jun 11, 2018

Adding inline comments to code examples would be helpful for beginners' comprehension in "Main Concepts" docs (along with the already provided explanations)!

Task

  • Comb through Main Concepts to clarify and enhance the learning experience by adding in comments to code snippets, and update plan below.

📚In current progress as of 7/8📚
WIP PR made #1048

Plan for Main Concepts

2. Introducing JSX

Embedding Expressions in JSX

  • Add comment in code snippet to assist with comprehension //Hello, Harper Perez!

JSX is an Expression Too

  • Add comments to code snippet, that it follows along with code example from above and what the function will return.

Specifying Attributes with JSX

  • Show code example of invalid JSX

JSX Represents Objects

  • Change "Babel compiles" to "Babel transpiles"
  • Add "It's helpful to keep this object model in mind" as we will explore rendering React elements to the DOM[...]

4. Components and Props

Functional and Class Components

  • Add: We'll show you how this code comes together with using "props" in Rendering a Component (several lines below).
    (Class Components)
  • Add:You may have noticed the this keyword in front of props.name.

Rendering a Component

  • Add explanation: We can name JSX attributes how we wish. In our component example, we chose name="Sara" (some naming conventions are required for Handling Events). When you write a JSX attribute inside of a component, think of it as adding key and value pairs to an object in JavaScript.
  • In example place comment underneath with // props: { name: "Sara"}

Composing Components

  • Add comments:
    renders the following and displays:
    Hello, Sara
    Hello, Cahal
    Hello, Edite

Extracting Components

  • In first code snippet, highlight Avatar block and comment // In the next example, we'll be extracting this block of code into its own component

  • In the second code snippet, add comment with highlighted Avatar component with \\ Avatar component will access props with user instead of author, explanation is below

5. State and Lifecycle

Converting a Function to a Class
Last 2 sentences

  • Add (with existing text) "''Since Clock is now defined as a class rather than a function, the this keyword inside of Clock points to its <Clock /> instance. In this case, that instance is inside of our ReactDOM.render() method.
  • Add to beginning of (last sentence) "Having defined our component as a class lets us...."

8. Lists and Keys

Keys

  • Display a variable for todos in an array of objects with an id and text property
  • In second todos example, display a variable for todos in an array of objects with no id and with text property
@JavaScriptErika
Copy link
Author

JavaScriptErika commented Jun 11, 2018

I'd 💙 to take on this task @gaearon!

I would update the tasks here of my current progress / plans and suggestions as I work on my PR before submitting it.

@gaearon
Copy link
Member

gaearon commented Jun 11, 2018

That sounds great, thank you!

@JavaScriptErika
Copy link
Author

@gaearon Here are my proposed additions for sections 2 - 8 that I'd like to begin implementing. I can expand on my outline too if needed.

@gaearon
Copy link
Member

gaearon commented Jun 27, 2018

Can you send the first few changes as a PR so I can get a better sense of the exact way you want to do them?

@JavaScriptErika
Copy link
Author

Absolutely! I'll work on that this coming up weekend- thanks!

@JavaScriptErika
Copy link
Author

I have been attempting to run the docs locally and get the error: Cannot find module '../build/Release/sharp.node' when I run yarn dev.

I did some research, and I removed .cache, installed node-gyp and the necessary window build tools. That helped me not receive any dependency errors when I ran yarn. I tried also adding sharp, and removed and reinstalled node_modules. Still getting that pesky error!

@alexkrolick
Copy link
Collaborator

alexkrolick commented Jul 1, 2018 via email

@JavaScriptErika
Copy link
Author

JavaScriptErika commented Jul 1, 2018

Thank you for getting back with me @alexkrolick !
Currently using 8.10.0

@alexkrolick
Copy link
Collaborator

alexkrolick commented Jul 3, 2018

Ok... you shouldn't have to install sharp or node-gyp manually, they should come in with the node_modules. Could be a yarn issue... try yarn cache clean and make sure you are on the latest version.

You can also try yarn remove gatsby-plugin-sharp gatsby-transform-sharp then add them back after everything else installs

@JavaScriptErika
Copy link
Author

🎉 Thank you so much @alexkrolick! That absolutely did the trick, and I think it was a yarn issue as you suggested (wasn't on the latest version). I kept track of what I did below so if someone comes across this with a similar issue, it can help!

rimraf node_modules (rimraf is a utility for nodejs)
yarn cache clean
yarn upgrade

I'll get working on the PR and submit a WIP sample of my suggestions here soon.

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

No branches or pull requests

3 participants