From 1384bef542740402287eff46c14d30d461471901 Mon Sep 17 00:00:00 2001 From: ahornbeck268 Date: Fri, 14 Jul 2017 13:41:06 -0500 Subject: [PATCH] prop practice done --- src/App.js | 40 ++++++++++++++++++++-------------------- src/components/Child.js | 3 +-- src/components/Parent.js | 32 ++++++++++++++++---------------- 3 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/App.js b/src/App.js index 2fe6d64..5422cf1 100644 --- a/src/App.js +++ b/src/App.js @@ -3,7 +3,7 @@ import "./App.css"; import PropTypes from "prop-types"; import SuperComponent from "./components/SuperComponent"; import Parent from "./components/Parent"; - +// import "./state.js"; /* eslint-disable no-unused-vars, no-console */ function App(props) { const product = { @@ -14,51 +14,51 @@ function App(props) { return (
{/* send in a prop called "message", give it the string "Hello World" */} -
This better say "Hello World":
+
This better say "Hello World":
{/* send in a prop called "message", give it the string "Goodbye World" */} -
This better say "Goodbye World":
+
This better say "Goodbye World":
{/* send in a prop called "message", give it the string "Props are awesome" */} -
This better say "Props are awesome":
+
This better say "Props are awesome":
{/* send in a prop called "message", give it the string "I totally get this now" */} -
This better say "I totally get this now":
+
This better say "I totally get this now":
{/* send in a prop called "magicNumber", give it the number 42*/} -
This better say 42:
+
This better say 42:
{/* send in a prop called "magicNumber", give it the number 21*/} -
This better say 21:
+
This better say 21:
{/* send in a prop called "product", give it the variable product*/} -
This better say "ajax":
+
This better say "ajax":
{/* send in a prop called "product", give it an object with a name property "pepsi"*/} -
This better say "pepsi":
+
This better say "pepsi":
{/* send in a prop called "product", give it an object with a name property "nike"*/} -
This better say "nike":
+
This better say "nike":
{/* send in a prop called "names", give it the variable names*/} -
This better say "Bob, Stand, Todd, Ted" :
+
This better say "Bob, Stand, Todd, Ted" :
{/* send in a prop called "names", give it an array ["Brodie","Alicia","Margo"]*/} -
This better say "Brodie, Alicia, Margo" :
+
This better say "Brodie, Alicia, Margo" :
{/* send in a prop called "names", give it an array ["Titus","Axel","Claire"]*/} -
This better say "Titus, Axel, Claire" :
+
This better say "Titus, Axel, Claire" :
{/* Use App's props*/} {/* send in a prop called "products", give it the products array from App's props*/} -
This better say "Hand Sanitizer":
+
This better say "Hand Sanitizer":
{/* send in a prop called "names", give it the names array from App's props*/} -
This better say "Robin, Lily, Barney":
+
This better say "Robin, Lily, Barney":
{/* send in a prop called "magicNumber", give it the magicNumber from App's props*/} -
This better say "99":
+
This better say "99":
{/* send in a prop called "message", give it the contact.firstName from App's props*/} -
This better say "Luke":
+
This better say "Luke":
{/* send in a prop called "message", give it the contact.lastName from App's props*/} -
This better say "Skywalker":
+
This better say "Skywalker":
{/* send in a prop called "message", give it the contact.occupation from App's props*/} -
This better say "farmer":
+
This better say "farmer":
{/* send in a prop called "message", give it the contact.address from App's props*/} -
This better say "300 MiddleOfNoWhere st Tatooine":
+
This better say "300 MiddleOfNoWhere st Tatooine":
); diff --git a/src/components/Child.js b/src/components/Child.js index a9276f7..8c56c3d 100644 --- a/src/components/Child.js +++ b/src/components/Child.js @@ -15,7 +15,7 @@ function Child(props) { street: "101 main st" city:"Austin", zip: "78741" - + } } @@ -39,4 +39,3 @@ function Child(props) { export default Child; - diff --git a/src/components/Parent.js b/src/components/Parent.js index 6cfbdb0..b84f9c5 100644 --- a/src/components/Parent.js +++ b/src/components/Parent.js @@ -6,33 +6,33 @@ function Parent(props) { return (
- {/* + {/* Child is just a function as you can obviously see from the code of Child.js We should understand how functions work else we are in big trouble - How many times can you call a function? - What can you send into functions as arguments? - How do you call a function? - How do you pass arguments into a functoin? - Using a component in JSX is the same as calling the function + How many times can you call a function?---up to you! + What can you send into functions as arguments?---whatever u need to! + How do you call a function?--fnc() + How do you pass arguments into a function? ---fnc(pass, args, here) + Using a component in JSX is the same as calling the function */} - {/* + {/* React converts the above into: var props = {name:"Bob"}; - Child(props) + Child(props) */} - - {/* + + {/* var props = {age:33}; - Child(props) + Child(props) */} - {/* + {/* var props = { address:{ street:"325 aca rd.", @@ -40,7 +40,7 @@ function Parent(props) { zip: "78701" } }; - Child(props) + Child(props) */} - {/* + {/* var props = { name: "Ted", age: 35, @@ -58,11 +58,11 @@ function Parent(props) { zip: "78701" } }; - Child(props) + Child(props) */}