Skip to content

Instantly share code, notes, and snippets.

@berkesayin
Created July 15, 2022 13:01
Show Gist options
  • Save berkesayin/c33b7e3f03caf78fbbc810bfe874a8e9 to your computer and use it in GitHub Desktop.
Save berkesayin/c33b7e3f03caf78fbbc810bfe874a8e9 to your computer and use it in GitHub Desktop.
React Hooks
import React, { useState } from 'react';
function Example() {
// Declare a new state variable, which we'll call "count"
const [count, setCount] = useState(0);
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>
Click me
</button>
</div>
);
}
function ExampleWithManyStates() {
// Declare multiple state variables!
const [age, setAge] = useState(42);
const [fruit, setFruit] = useState('banana');
const [todos, setTodos] = useState([{ text: 'Learn Hooks' }]);
// ...
}
@berkesayin
Copy link
Author

React ile State Hooks kullanımı örneği.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment