• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/19

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

19 Cards in this Set

  • Front
  • Back

HOC =


They make your code




example - React Router

High Order Components


more clean, efficient, modular




with router - get history, match, location

“render prop”


render function getting replaced by___.

refers to a technique for sharing code between React components using a prop whose value is a function.




createRoot

custom hooks good to inlcude 2 things

value and function to update the value



simple counter component bare bones syntax


9 pieces


Hints


1) 3 pairs


2) 2 consts


3) Button





1const Statey1 = () => { [pair]


2const [art, setArt] = useState(1);


3return ( [pair]




4

[pair]

5


7




7);


8};


9 export default Statey1;

Axios example Part 1 -


1function body


2 next part


3 1 method

Const fetchRandomData = () => {


return axios


.get("www.randomdata.com/api")





Part 2


2 methods

.then (({data}) => {console.log(data);


return JSON.stringify(data, 2, null) ;});

part 3


4 lines


1- method


2 function


3 syntax


4 syntax

.catch((err) => {


console.log("wee focked")


})


;};

Disable button


1 import


2 function syntax


3 hook

import { useState } from 'react';




function MyComponent() {



const [inputValue, setInputValue] = useState('');

handle 2 parts

function handleInputChange(e) {




setInputValue(e.target.value); }

UI code


4 parts

return (


<>



onChange={handleInputChange

button that changes


event


button that disables

input value={inputValue} onChange={(e) =>


setInputValue(e.target.value)} />




button disabled={isButtonDisabled}

2 way data binding


5 lines of code


1 element


2


3 event


4 event


5 ui


[value, setValue] = React.useState("");


value={value} onChange={(e) => setValue(e.target.value)}




{value}

value is a




input is a





attribute








form element



make an input controlled by passing one of these props




2 types of props for 3 things

checked: A boolean. For a checkbox input or a radio button, controls whether it is selected.




value: A string. For a text input, controls its text. (For a radio button, specifies its form data.)




checkbox, radio button, or text input

Child to update


6 lines


1 arg


2 frag


3element


4 updating logic cont


5 end grad


6 end component

const Child = ({ setValue }) => (


<>


button onClick={() => setValue("Parent has been updated!")}>Change Parent Value


< / >


);



Child Code in the Parent Component

Child setValue={setValue} />

Mapping out prisma data


3 lines


1map + ____


line 2 the data syntax


3 - closing syntax

{state.searchResults.map((result) => ( {result.date} {result.time}

))}

line 2 from data involves 2 things

- destructuring




- an api call object called result

Returning a Clean Result 5 main things

const cleanResult = results.map((artist) => ({ ...artist, id: "abc" })); return { props: { results: JSON.parse(JSON.stringify(cleanResult)) } };