From e99bca5f49fb389110b41b64601f62438fa2a30d Mon Sep 17 00:00:00 2001 From: kinana52 <93495806+kinana52@users.noreply.github.com> Date: Tue, 8 Feb 2022 01:16:06 -0800 Subject: [PATCH] Delete 003: DOM and Javascript.md --- 003: DOM and Javascript.md | 231 ------------------------------------- 1 file changed, 231 deletions(-) delete mode 100644 003: DOM and Javascript.md diff --git a/003: DOM and Javascript.md b/003: DOM and Javascript.md deleted file mode 100644 index 3285c6d1..00000000 --- a/003: DOM and Javascript.md +++ /dev/null @@ -1,231 +0,0 @@ -# Hack School: Part 3 - DOM Manipulation, React (10/29) - -Slides Link: [here](acmurl.com/hackschool-fa20-pt3) - -Workshop Recording: [here](https://www.youtube.com/channel/UCyjPATFqc3FwOiuqJ2UG1Eg) - - -In the first part of this workshop, we learned about DOM and React. Specifically, we learned **how to access elements using JavaScript and DOM**, **the difference between React and HTML**, **components**, and **props**. - -We used these ideas to to: -- [x] Download React -- [x] Change the style in NavBar -- [x] Create Pokemon.jsx as a React component - - -## What is DOM? - - - -DOM is the tree structure that organizes HTML elements. JavaScript uses the DOM organization to access HTML elements--like how you might use an address to find a location. - -The tree structure follows that of any family tree. -- The element directly above is considered a parent (for example, on the far left, the `Element:
Hello!
-``` -Now, using Javascript, we can grab elements and change its different features. - -#### Selecting by ID -``` -document.getElementById(Hello!
-Goodbye!
-``` -If you want to select the "Goodbye" paragraph, you would input [1] into the index, since Goodbye is the second paragraph and the HTML index starts counting at 0. - -(Which means that in most coding language, "Hello" would be the 0th paragraph and "Goodbye" would be the 1st paragraph.) - -#### `.innerHTML` - -`.innerHTML` is a function that grabs the inner content in between the HTML tags. From there, you can change its innerHTML property. - -For example: -``` -document.getElementById("demo").innerHTML - "Hello World!"; -``` -would change `Hello!
` to `Hello World!
` - -#### `.style.color` - -`.style.color` is a function that accesses an element's style description, and then looks specifically for color in that description. From there, you can change an element's color. - -For example: -``` -document.getElementsByClassName("para")[0].style.color = "blue"; -``` -would change `Hello!
` to blue text. - -## What is React? - -React is a very commonly used front-end framework that has many benefits, including: - -- You can import and re-use components easily -- The webpage only re-renders updated components, so page-rendering is faster -- Don't need to manually update - -React is a javascript framework where you can import external components like CSS and HTML is treated as variable objects, so you can re-use them whenever necessary. - -Note: React uses **className** instead of **class** in HTML. - -#### What are components? -``` -const Example = () => { - returnThis is a component!
-} -``` -Components are code blocks on your websites that do different things. There are two types of components, *functional* and *class*. - -Components are rendered in *return* statements for functional components and the *render()* function for class components. - -You can see above that the example is a functional component because it has `return` in it. If the example didn't have return, it wouldn't render anything; that is, no "This is a component!" paragraph would show up on your webpage. - -#### Functional components - -``` -const MemeSong = (props) => { - return( -Jam to this song with me here!
-Jam to this song with me - here! -
-import
each component from .location
? Remember, if you don't import, your code won't be able to use it!
-export default
each component? If you don't export them, you can't access them in other files!
-class
to className
? Remember, we need to do that when switching HTML to React!
-