Skip to content

Instantly share code, notes, and snippets.

😎

ckomop0x ckomop0x

😎
Block or report user

Report or block ckomop0x

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ckomop0x
ckomop0x / main.js
Created Jun 13, 2019
Final compiled main.js chunk
View main.js
(window.webpackJsonp = window.webpackJsonp || []).push([[0], {
10: function(e, n, a) {
"use strict";
a.r(n);
var t = a(0)
, r = a.n(t)
, l = a(2)
, p = a.n(l);
// Here is our sum
function c(e, n) {
@ckomop0x
ckomop0x / App.js
Created Jun 13, 2019
Final App.js
View App.js
import React from "react";
import ReactDOM from "react-dom";
import { multiply, sum, calculateSomethingSpecial } from "./utils";
import "./styles.css";
function App() {
const specialData = [
{
param1: 100,
param2: 99
},
@ckomop0x
ckomop0x / main.js
Created Jun 13, 2019
Compiled for production main.js chunk
View main.js
(window.webpackJsonp = window.webpackJsonp || []).push([[0], {
10: function(e, n, t) {
"use strict";
t.r(n);
var a = t(0)
, r = t.n(a)
, c = t(2)
, l = t.n(c);
t(9);
var o = document.getElementById("root");
@ckomop0x
ckomop0x / main.js
Created Jun 13, 2019
Compiled for production main.js chunk
View main.js
(window.webpackJsonp = window.webpackJsonp || []).push([[0], {
10: function(e, n, t) {
"use strict";
t.r(n);
// So here is our function compiled inside a component
var r = t(0)
, a = t.n(r)
, c = t(2)
, o = t.n(c);
function l(e, n) {
@ckomop0x
ckomop0x / App.js
Created Jun 13, 2019
Rewritten App.js
View App.js
import React from "react";
import ReactDOM from "react-dom";
import { sum } from "./utils";
import "./styles.css";
function App() {
return (
<div className="App">
<h1>Re-export example</h1>
<p>{sum(5, 10)}</p>
</div>
@ckomop0x
ckomop0x / App.js
Created Jun 13, 2019
Now, we can rewrite out the weirdness:
View App.js
import { multiply, sum, calculateSomethingSpecial } from '../utils';
@ckomop0x
ckomop0x / index.js
Created Jun 13, 2019
index.js inside utils folder
View index.js
export { default as sum } from './sum';
export { default as multiply } from './multiply';
export { default as calculateSomethingSpecial } from './calculateSomethingSpecial';
@ckomop0x
ckomop0x / App.js
Last active Jun 13, 2019
import refactored functions
View App.js
import multiply from '../utils/multiply';
import sum from '../utils/sum';
import calculateSomethingSpecial from '../utils/calculateSomethingSpecial';
@ckomop0x
ckomop0x / calculateSomethingSpecial.js
Created Jun 13, 2019
calculateSomethingSpecial.js refactored to a file
View calculateSomethingSpecial.js
import sum from "./sum";
export default function calculateSomethingSpecial(data) {
return data.map(
dataItem => sum(dataItem.param1, dataItem.param2));
}
@ckomop0x
ckomop0x / sum.js
Created Jun 13, 2019
sum.js refactored to a file
View sum.js
export default function sum (a, b) {
return a + b;
}
You can’t perform that action at this time.