Skip to content

Instantly share code, notes, and snippets.

View ManasJayanth's full-sized avatar

prometheansacrifice ManasJayanth

View GitHub Profile
@ManasJayanth
ManasJayanth / index-that-requires-custom-renderer.js
Created June 22, 2018 03:28
Snippets for Learn you some custom react renderers
import React from 'react';
import ReactDOM from './renderer.js';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
@ManasJayanth
ManasJayanth / renderer-with-only-render-function.js
Created June 22, 2018 04:07
Snippets for Learn you some custom react renderers
import ReactReconciler from 'react-reconciler';
const hostConfig = {};
const DOMRenderer = ReactReconciler(hostConfig);
let internalContainerStructure;
export default {
render(elements, containerNode, callback) {
// We must do this only once
@ManasJayanth
ManasJayanth / empty-host-config.js
Last active July 8, 2018 14:49
Snippets for Learn you some custom react renderers
const hostConfig = {
getRootHostContext(rootContainerInstance) {
},
getChildHostContext(parentHostContext, type, rootContainerInstance) {
},
getPublicInstance(instance) {
},
import ReactReconciler from 'react-reconciler';
const hostConfig = {
getRootHostContext(rootContainerInstance) {
return {}
},
getChildHostContext(parentHostContext, type, rootContainerInstance) {
return {};
},
finalizeInitialChildren(
domElement,
type,
props,
rootContainerInstance,
hostContext
) {
const { children, ...otherProps } = props;
Object.keys(otherProps).forEach(attr => {
if (attr === 'className') {
import React, { Component } from 'react';
class App extends Component {
constructor() {
super();
this.state = {
count: 0
};
}
render() {
prepareUpdate(
domElement,
type,
oldProps,
newProps,
rootContainerInstance,
hostContext
) {
const propKeys = new Set(
Object.keys(newProps).concat(
commitUpdate(
domElement,
updatePayload,
type,
oldProps,
newProps,
internalInstanceHandle
) {
updatePayload.forEach(update => {
Object.keys(update).forEach(key => {
import ReactReconciler from 'react-reconciler';
const hostConfig = {
getRootHostContext(rootContainerInstance) {
return {}
},
getChildHostContext(parentHostContext, type, rootContainerInstance) {
return {};
},
@ManasJayanth
ManasJayanth / script.js
Created July 27, 2018 06:33
Debalina - zipcode search with tries
const root = document.getElementById('root');
class TrieNode{
constructor(c) {
this.key = c;
this.parent = null;
this.children = {}; // Hash mapping character to next level
this.end = false; // End of node
this.data = null
}