Skip to content

Instantly share code, notes, and snippets.

@dnshko
dnshko / ENTERING REACT AFTER LEARNING JAVASCRIPT.js
Last active July 31, 2020 10:22
ENTERING REACT AFTER LEARNING JAVASCRIPT
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
@dnshko
dnshko / REACT AND JAVASCRIPT CLASSES.js
Last active July 31, 2020 10:25
REACT AND JAVASCRIPT CLASSES
class Developer {
constructor(firstname, lastname) {
this.firstname = firstname;
this.lastname = lastname;
}
getName() {
return this.firstname + ' ' + this.lastname;
}
}
@dnshko
dnshko / entity.JS
Created July 31, 2020 10:28
entity
class Developer {
constructor(firstname, lastname) {
this.firstname = firstname;
this.lastname = lastname;
}
getName() {
return this.firstname + ' ' + this.lastname;
}
}
import React, { Component } from 'react';
class App extends Component {
render() {
return (
<div>
<h1>Welcome to React</h1>
</div>
);
}
import React, { Component } from 'react';
class App extends Component {
getGreeting() {
return 'Welcome to React';
}
render() {
return (
<div>
// JavaScript ES5 function
function getGreeting() {
return 'Welcome to JavaScript';
}
// JavaScript ES6 arrow function with body
const getGreeting = () => {
return 'Welcome to JavaScript';
}
function (props) {
return view;
}
function Greeting(props) {
return <h1>{props.greeting}</h1>;
}
// JavaScript ES5 function
function Greeting(props) {
return <h1>{props.greeting}</h1>;
}
// JavaScript ES6 arrow function
const Greeting = (props) => {
return <h1>{props.greeting}</h1>;
}
@dnshko
dnshko / REACT CLASS COMPONENT SYNTAX.js
Created July 31, 2020 10:41
REACT CLASS COMPONENT SYNTAX
class Counter extends Component {
constructor(props) {
super(props);
this.state = {
counter: 0,
};
this.onIncrement = this.onIncrement.bind(this);
this.onDecrement = this.onDecrement.bind(this);