Skip to content

Instantly share code, notes, and snippets.

I'm often tempted to jump into the source code of the framework/libraries that I consume. In react, the source code lies inside the /src folder https://github.com/facebook/react/tree/master/src

To start with, the best way is to go through the modules with no or less dependencies. Usually, the utils will have less dependencies but they would be consumed a lot throughout. So, I feel its good to start with them.

React shares some utilities from https://github.com/facebook/fbjs

  1. invariant
  2. keyMirror
  3. keyOf
  4. emptyFunction

Its been a month since I dove into react. Its an incredible journey, where I just concentrated in learning more things.

Stepping into second month of my react journey,

  • If you have some unwanted properties in your props, do not drop all of them using {...props} to the child component. Pass the props that are needed by the component. (facebook/react#7157 (comment))
// BAD (if there are unwanted props)
render() {
  return (
    <Foo {...this.props} />
  );
}
@selvagsz
selvagsz / controllers.application.js
Created September 19, 2016 04:17
model-proxy-removal
import Ember from 'ember';
Ember.ObjectController.reopen({
unknownProperty(prop) {
console.log(prop, this._debugContainerKey);
// log the info to your server
return this._super(prop);
},
@selvagsz
selvagsz / index.md
Last active May 24, 2017 15:15
Immutable <==> JS

Object <==> Map

Creation

// js
let foo = {}

// Immutablejs
let bar = Map()
let a = {
name: 'selva'
}
let zfoo = {
foo: {
name: 'a',
ofo: {
bar: a
}
@selvagsz
selvagsz / webpack-notes.js
Last active October 24, 2016 08:22
Webpack Notes
// Entire default options
{
devtool: false,
cache: true,
context: process.cwd(),
target: 'web',
module: {
unknownContextRequest: '.',
@selvagsz
selvagsz / promise_and_deferred.js
Created November 3, 2016 19:58
Diff between native promise & $.Deferred promise chain
// Check the console logs by uncommenting the error throwing scenario also
function one() {
console.log('one')
throw new Error('error1')
}
function two() {
console.log('two')
}
@selvagsz
selvagsz / index.html
Last active June 7, 2018 07:59
razorpayjs-card-payment
<script type="text/javascript" src="https://checkout.razorpay.com/v1/razorpay.js"></script>
<div class="container payment-container">
<form id='card_payment'>
<div class="form-group">
<label for="card_number">Card Number:</label>
<input id="card_number" class="form-control" placeholder='XXXX XXXX XXXX XXXX' maxlength=19 />
</div>
<div class="row">