Skip to content

Instantly share code, notes, and snippets.

View riquito's full-sized avatar

Riccardo Attilio Galli riquito

View GitHub Profile

Keybase proof

I hereby claim:

  • I am riquito on github.
  • I am riquito (https://keybase.io/riquito) on keybase.
  • I have a public key whose fingerprint is 3DBC 89B5 5FBE 7FFC 2251 1700 7DDD E7C6 2598 3A25

To claim this, I am signing this object:

@riquito
riquito / withShouldComponentUpdate.js
Created April 16, 2018 15:30
Wrap a component with a shouldComponentUpdate call
import React, { Component, Fragment } from 'react';
export const withShouldComponentUpdate = (WrappedComponent, func) => {
class WithShouldComponentUpdate extends Component {
displayName = `WithShouldComponentUpdate(${getDisplayName(
WrappedComponent,
)})`;
shouldComponentUpdate = (nextProps, nextState) =>
func.call(this, nextProps, nextState);
render = () => (
@riquito
riquito / makeWithConsumer.js
Created September 12, 2018 05:34
Create an higher order component that receives props from a context consumer.
/**
* Create an higher order component that receives props from a context consumer.
*
* // e.g. Create your with<SomeConsumer> function
* // const withDispatch = makeWithConsumer(DispatchContext.consumer, 'Dispatch')
*
* // e.g. pass the consumer props as they are
* const ButtonConnected = withDispatch(Button)
*
@riquito
riquito / changed-since.mjs
Created February 24, 2023 06:22
retrieve workspaces that have changed since ref, after applying ignore rules / get which package depend on another in a monorepo
// Copyright (c) 2023 Riccardo Attilio Galli. All rights reserved.
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
// So, ideally yarn workspaces list --json -R --since=HEAD~
// would give use what we want
// We want a list of packages (and perhaps their locations) that
// have been meaningfully modified.