Skip to content

Instantly share code, notes, and snippets.

@berkesayin
berkesayin / .js
Created March 18, 2022 16:11
Tweet-component
import React, {Component} from 'react';
import Tweet from '../component/Tweet';
class Timeline extends Component {
render() {
return (
<div>
<Tweet />
</div>
);
}
const element = <h1>Hello, world!</h1>;
@berkesayin
berkesayin / .js
Created March 18, 2022 16:13
Props
import React, { Component } from 'react';
import Tweet from '../component/Tweet';
const tweet = [
{
tweet_id: 1,
tweet_topic: "Sports",
tweet_detail: "Liverpool, Manchester City ile arasındaki puan farkını 1'e düşürdü."
},
{
tweet_id: 2,
@berkesayin
berkesayin / .js
Created March 18, 2022 16:15
Key
import { Component } from "react";
class Tweet extends Component {
render() {
return (
<div>
{this.props.tweet.map(tweet =>
<div key={news.tweet_id}>
{tweet.tweet_topic}
<br />
{tweet.tweet_detail}
@berkesayin
berkesayin / .js
Created March 18, 2022 16:16
State
constructor(props) {
super(props);
this.state = {
categories:
[
{categoryId: 1, categoryName: "Sports" },
{categoryId: 2, categoryName: "Economy"}
]
};
}
@berkesayin
berkesayin / app.js
Last active May 8, 2024 15:09
props
import React, { Component } from 'react';
import Tweet from '../component/Tweet';
const tweet = [
{
tweet_id: 1,
tweet_topic: "Sports",
tweet_detail: "Liverpool, Manchester City ile arasındaki puan farkını 1'e düşürdü."
},
{
tweet_id: 2,
@berkesayin
berkesayin / key.js
Last active June 27, 2022 14:22
Key
import { Component } from "react";
class Tweet extends Component {
render() {
return (
<div>
{this.props.tweet.map(tweet =>
<div key={tweet.tweet_id}>
{tweet.tweet_topic}
<br />
{tweet.tweet_detail}
@berkesayin
berkesayin / state-hook.js
Created July 15, 2022 13:01
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)}>
dev
├── build
│ └── logs
│ │ └── debug_a.log
│ │ └── debug_b.log
│ │ └── debug_c.log
├── tests
│ └── test1.js
│ └── test2.js
// Validation For Credit Card Numbers Using Luhn Algorithm
const validateCreditCardNumber = (input) => {
// Kredi kartı numarasını sayısal bir diziye dönüştürme
let creditCardInt = input.split("").map(Number);
// Luhn Algoritması gereği her ikinci basamağı sondan başlayarak ikiyle çarparız
for (let i = creditCardInt.length - 2; i >= 0; i = i - 2) {
// Seçilen her ikinci basamağı geçici bir değişkende saklarız
let tempValue = creditCardInt[i];