Skip to content

Instantly share code, notes, and snippets.

@sorenlouv
sorenlouv / determine-changed-props.js
Last active July 21, 2023 02:23
Determine which props causes React components to re-render
import React, { Component } from 'react';
export default function withPropsChecker(WrappedComponent) {
return class PropsChecker extends Component {
componentWillReceiveProps(nextProps) {
Object.keys(nextProps)
.filter(key => {
return nextProps[key] !== this.props[key];
})
.map(key => {
@bradley
bradley / gist:2484138
Created April 24, 2012 21:47
Create new JS object for each input field and send AJAX call when user stops typing.
// =========== Input Field Listener with AJAX Callback ==============
function FieldListener(entity){
var t = this;
this.typingTimer; // Timer identifier
this.doneTypingInterval = 750; // Time in ms. e.g.; 5000 = 5secs
this.entity = entity;
this.noticeSpan = this.entity.siblings("span");
this.parentForm = entity.parents('form:first');
entity.on("keyup", function(){t.setTimer();});