Skip to content

Instantly share code, notes, and snippets.

View berkelmas's full-sized avatar
🎯
How would you React if I said I love Angular?

Berk Elmas berkelmas

🎯
How would you React if I said I love Angular?
View GitHub Profile
import React, {useState} from "react";
const ExampleComponent = props => {
const [exampleState, setExampleState] = useState({name: "Berk"});
const changeName = () => {
// setExampleState will provide us with changing state;
// setExampleState will also provide previous state if we want to use it.
setExampleState(prev => ({name: "Changed..."}));
}
import React, {useEffect, useState} from "react";
const ExampleUseEffect = props => {
const [exampleState, setExampleState] = useState({name: "Berk"})
useEffect(() => {
console.log("I execute in component's first render.")
}, []);
useEffect(() => {