This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "react-rate-component", | |
| "version": "1.0.0", | |
| "description": "react rating component with custom symbol", | |
| "main": "index.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "repository": { | |
| "type": "git", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| npm i react react-dom webpack webpack-cli webpack-dev-server html-webpack-plugin style-loader css-loader babel-core babel-loader@7.1.4 babel-preset-env babel-preset-react -D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mkdir react-rate-component | |
| cd react-rate-component | |
| npm init |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function App() { | |
| const [inputValue, setValue] = useState("reactjs"); | |
| const [subreddit, setSubreddit] = useState(inputValue); | |
| const handleSubmit = e => { | |
| e.preventDefault(); | |
| setSubreddit(inputValue); | |
| }; | |
| return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Reddit({ subreddit }) { | |
| const [posts, setPosts] = useState([]); | |
| useEffect(async () => { | |
| const res = await fetch( | |
| `https://www.reddit.com/r/${subreddit}.json` | |
| ); | |
| const json = await res.json(); | |
| setPosts(json.data.children.map(c => c.data)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useEffect, useState } from "react"; | |
| import ReactDOM from "react-dom"; | |
| function Reddit() { | |
| const [posts, setPosts] = useState([]); | |
| useEffect(async () => { | |
| const res = await fetch( | |
| "https://www.reddit.com/r/reactjs.json" | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useEffect, useState, useRef } from "react"; | |
| import ReactDOM from "react-dom"; | |
| function App() { | |
| const inputRef = useRef(); | |
| const [value, setValue] = useState(""); | |
| useEffect( | |
| () => { | |
| console.log("render"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| useEffect(() => { | |
| console.log('mounted'); | |
| return () => console.log('unmounting...'); | |
| }, []) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const [value, setValue] = useState('initial'); | |
| useEffect(() => { | |
| console.log(value); | |
| }, [value]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Kim, neden, neyi, ne için extends ediyor? | |
| class Counter extends Component { | |
| // State'i direk tanımlayabilir miyiz? | |
| state = { value: 0 }; | |
| // Neden props kullanıyoruz? | |
| // constructor(props) { | |
| // | |
| // super ne alaka? | |
| // super(props); |