Skip to content

Instantly share code, notes, and snippets.

View thatisuday's full-sized avatar
🤖

Uday Hiwarale thatisuday

🤖
View GitHub Profile
@thatisuday
thatisuday / react-v8-root.tsx
Created April 16, 2022 23:46
Creating root in React v18
// v17 and below
import ReactDOM from 'react-dom';
const container = document.getElementById('app');
ReactDOM.render(<App />, container);
// v18
import { createRoot } from 'react-dom/client';
const container = document.getElementById('app');
const root = createRoot(container);
root.render(<App />);
@thatisuday
thatisuday / try-catch-nested.js
Last active April 17, 2022 02:20
React Suspense try/catch analogy
const a = () => {throw new Error('Oops!')};
const b = () => a();
const c = () => b();
try {
try {
c();
console.log('Child worked.');
} catch (e) {
console.log("Error inside child", e?.message);
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _config() {
const data = require("./config");
@thatisuday
thatisuday / log.txt
Last active January 8, 2021 05:28
npm run pack command log
$ npm run pack
> electron-lessons@1.0.0 pack /Projects/thatisuday/electron-lessons
> electron-builder -mwl
• electron-builder version=22.9.1 os=20.1.0
• loaded configuration file=/Projects/thatisuday/electron-lessons/electron-builder.json
• Specified application directory equals to project dir — superfluous or wrong configuration appDirectory=.
• writing effective config file=out/builder-effective-config.yaml
• packaging platform=darwin arch=x64 electron=11.1.1 appOutDir=out/mac
@thatisuday
thatisuday / package.json
Last active December 29, 2021 19:01
A sample package.json file for the electron-builder
{
"name": "electron-lessons",
"version": "1.0.0",
"description": "A sample Electron (JS) project for Medium lessons.",
"main": "app/index.js",
"scripts": {
"start": "electron .",
"postinstall": "electron-builder install-app-deps",
"pack": "electron-builder -nwl"
},
@thatisuday
thatisuday / electron-builder.json
Created January 8, 2021 04:32
A simple electron-builder configuration.
{
"appId": "com.thatisuday.fileio",
"productName": "Electron File IO",
"copyright": "THATISUDAY TECH PVT. LTD.",
"directories": {
"app": ".",
"output": "out",
"buildResources": "build-res"
},
"files": [
.hello {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
&__btn {
&--odd {
background-color: beige;
}
@thatisuday
thatisuday / index.js
Last active January 5, 2021 13:25
A sample React component with increment button.
import React, { useState } from 'react';
// local dependencies
import { getVersion } from 'common/util';
// import styles (for compilation)
import './styles.scss';
// export a react component
export default ( props ) => {
@thatisuday
thatisuday / index.js
Created January 5, 2021 12:22
electron-webpack renderer entrypoint.
import React from 'react';
import ReactDOM from 'react-dom';
// import entry component
import Entry from './entry';
// render `Entry` component
ReactDOM.render(
<Entry name='React'/>,
document.getElementById( 'app' ),
{
"name": "electron-lessons",
"scripts": {
"start": "electron-webpack dev",
"build": "electron-webpack"
},
"devDependencies": {
"electron": "^11.1.1",
"electron-webpack": "^2.8.2",
"webpack": "^4.44.2"