This file contains 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
def unique_in_order(iterable): | |
listofargs = [x for x in (list(iterable))] | |
uniqueList = [] | |
prevItem = None | |
for item in listofargs: | |
if item == prevItem: | |
prevItem = item | |
continue | |
else: | |
uniqueList.append(item) |
This file contains 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
{ | |
"main": "dist/tevreact.umd.js", | |
"module": "dist/tevreact.es.js", // ESM-aware tools like Rollup need this field to import the es module directly | |
"name": "tevreact", | |
"version": "1.0.0", | |
"license": "MIT", | |
"files": [ | |
"dist" | |
], | |
"scripts": { |
This file contains 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
Show hidden characters
{ | |
"presets": [ | |
[ | |
"@babel/preset-env", | |
{ | |
"targets": { | |
"node": "current" | |
} | |
} | |
] |
This file contains 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
//NB: ALL DOM nodes have their corresponding fibers in our new implementation | |
// most of this properties will make sense once we begin using them | |
let fiber = { | |
tag: HOST_COMPONENT, // we can have either host of class component | |
type: "input", | |
parent: parentFiber, // the parentNode’s fiber | |
child: childFiber, // the childNode’s fiber if it has any | |
sibling: null, // the element that is in the same tree level as this input | |
alternate: currentFiber, // the fiber that has been rendered on the dom. Will be null if its on initial render | |
stateNode: document.createElement(“div”), |
This file contains 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 rootElement = document.getElementById("root") | |
ReactDom.render(<Component />, rootElement) // renders for the first time | |
ReactDom.render(<Component />, rootElement) // does the app component render twice |
This file contains 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
$ yarn init -y // if you have yarn installed | |
$ npm init -y // if you have npm | |
// install rollup | |
$ yarn add rollup —-dev | |
$ npm install rollup —-save-dev |
This file contains 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 root = document.getElementById("root") | |
ReactDom.render(<Component />, root) |
This file contains 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
// .. code | |
const PLACEMENT = "PLACEMENT"; // this is for a child that needs to be added | |
const DELETION = "DELETION"; //for a child that needs to be deleted. | |
const UPDATE = "UPDATE"; // for a child that needs to be updated. refresh the props | |
function createArrayOfChildren(children) { | |
// we can pass children as an array now in the call to render | |
/** |
This file contains 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
function performWork(deadline) { | |
if (!nextUnitOfWork) { | |
// on initial render | |
// or if all work is complete and the nextUnitOfWork is null | |
//grab the first item on the workInProgress queue. | |
initialUnitOfWork(); | |
} | |
loopThroughWork(deadline) | |
if (nextUnitOfWork || workQueue.length > 0) { | |
// if theres more work to be done. get to know when the browser will be occupied |
This file contains 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 CLASS_COMPONENT = "class"; | |
// ...code | |
export function scheduleUpdate(instance, partialState) { | |
workQueue.push({ | |
from: CLASS_COMPONENT, // we know scheduleUpdate came from a class so we have CLASS_COMPONENT here. | |
instance: instance, // *this* object | |
partialState: partialState // this represents the state that needs to be changed | |
}); | |
requestIdleCallback(performWork); |
NewerOlder