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, { Component } from 'react' | |
import axios from 'axios' | |
class GenericErrorReq extends Component { | |
constructor(props) { | |
super(props) | |
this._callBackend = this._callBackend.bind(this) | |
} |
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, { Component } from 'react' | |
import axios from 'axios' | |
import InlineError from './InlineError' | |
class SpecificErrorRequest extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { |
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, { Component } from 'react' | |
import axios from 'axios' | |
import InlineError from './InlineError' | |
class SpecificErrorRequest extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { |
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
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 |
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 CustomError = require('./CustomError') | |
const nativeError = new Error('ehqo') | |
const myErr = new CustomError('qweqwe') | |
console.log(nativeError.isCustomError) // undefined | |
console.log(myErr.isCustomError) // true |
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
class Counter { | |
constructor() { | |
this.count = 5 | |
this.add = function() { | |
this.count++ | |
} | |
} | |
copy() { |
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
// 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 { |
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
// BAD EXAMPLE | |
class Viking { | |
constructor(name) { | |
this.name = name | |
} | |
prepareForBattle(increaseCount) { | |
console.log(`I am ${this.name}! Let's go fighting!`) | |
increaseCount() | |
} |
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 drinks = [ | |
{ | |
name: 'Coffee', | |
addictive: true, | |
info: function() { | |
console.log(`${this.name} is ${this.addictive ? '' : 'not '} addictive.`) | |
}, | |
}, | |
{ | |
name: 'Celery Juice', |
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
async function getData() { | |
const result = await axios.get('https://dube.io/service/ping') | |
const data = result.data | |
console.log('data', data) | |
return data | |
} | |
getData() |