Skip to content

Instantly share code, notes, and snippets.

View morajabi's full-sized avatar

Mo morajabi

View GitHub Profile
@morajabi
morajabi / ErrorBoundary.js
Last active November 22, 2020 00:46
React 16 Error Boundary component - for electron app (https://there.pm)
import React, { Component } from 'react'
class ErrorBoundary extends Component {
state = {
error: null,
hasError: false,
showError: false,
}
componentDidCatch(e) {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Untitled benchmark</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@morajabi
morajabi / clone-object.js
Created June 22, 2017 13:27
Cloning objects in javascript with Object.assign({}, src)
console.group("Cloning objects");
const firstObject = {
name: 'Mohammad',
};
const clonedObject = Object.assign({}, firstObject);