React Hooks

import { useState } from 'react';
[name, setName] = useState("programmer") 
//name in state will default to programmer
const eventToChangeName = () => {
setName("Adam")
}
//name will be Adam after function is called
useEffect(() => {
eventToChangeName()
}, [])
cont pets = {
bobo: 'Cat' ,
lucy: 'Dog'
}
const PetContext = createContext(pets);function App(props) {
return(
<PetContext.Provider value={pets.bobo}>
<FindTheAnimal /> </PetContext.Provider>
)
}
function FindTheAnimal = () => {
const animal = useContext(PetContext)
return (
<p> animal </p>
)
}
function App() {   const myButton = useRef(null)   const click = () => myButton.current.click()   return(
<button ref={myButton}> </button>
)
}
const [counter, setCounter] = useState(2)const expensiveCount = useMemo(() => {
return count ** 2
}, count)

--

--

--

Student at The Flatiron School in Washington DC

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to Use Software Fundamentals Outside Of Programming

3 Ways To Not Copy Objects in JavaScript (Spread, Assign & JSON)

What is Template Method Design Pattern?

Mapping State to Props in Redux/React

Fundamental Concepts of React.js

Micro Frontends with Webpack 5 Module Federation and React

WordPress + Create React App Integration

Choose the Best JavaScript Framework for Your Server-Side Development

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adam Adolfo

Adam Adolfo

Student at The Flatiron School in Washington DC

More from Medium

React Hooks

React class components