Skip to content

Instantly share code, notes, and snippets.

View gisderdube's full-sized avatar

Lukas Gisder-Dubé gisderdube

View GitHub Profile
import React, { Component } from 'react'
import axios from 'axios'
class GenericErrorReq extends Component {
constructor(props) {
super(props)
this._callBackend = this._callBackend.bind(this)
}
import React, { Component } from 'react'
import axios from 'axios'
import InlineError from './InlineError'
class SpecificErrorRequest extends Component {
constructor(props) {
super(props)
this.state = {
import React, { Component } from 'react'
import axios from 'axios'
import InlineError from './InlineError'
class SpecificErrorRequest extends Component {
constructor(props) {
super(props)
this.state = {
class CustomError extends Error {
constructor(code = 'GENERIC', status = 500, ...params) {
super(...params)
if (Error.captureStackTrace) {
Error.captureStackTrace(this, CustomError)
}
this.code = code
this.status = status
const CustomError = require('./CustomError')
const nativeError = new Error('ehqo')
const myErr = new CustomError('qweqwe')
console.log(nativeError.isCustomError) // undefined
console.log(myErr.isCustomError) // true
class Counter {
constructor() {
this.count = 5
this.add = function() {
this.count++
}
}
copy() {
// BAD EXAMPLE
import React from 'react'
class Child extends React.Component {
render() {
return <button onClick={this.props.getCoffee}>Get some Coffee!</button>
}
}
class Parent extends React.Component {
// BAD EXAMPLE
class Viking {
constructor(name) {
this.name = name
}
prepareForBattle(increaseCount) {
console.log(`I am ${this.name}! Let's go fighting!`)
increaseCount()
}
const drinks = [
{
name: 'Coffee',
addictive: true,
info: function() {
console.log(`${this.name} is ${this.addictive ? '' : 'not '} addictive.`)
},
},
{
name: 'Celery Juice',
async function getData() {
const result = await axios.get('https://dube.io/service/ping')
const data = result.data
console.log('data', data)
return data
}
getData()