Skip to content

Instantly share code, notes, and snippets.

Manuel Beaudru mbeaudru

Block or report user

Report or block mbeaudru

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View useSpotifyAccessToken.js
import { useReducer, useEffect } from 'react';
import Cookies from 'js-cookie';
import SpotifyWebApi from 'spotify-web-api-js';
import qs from 'query-string';
const INVALIDATE_TOKEN = 'INVALIDATE_TOKEN';
const USE_TOKEN = 'USE_TOKEN';
const SPOTIFY_ACCESS_TOKEN_COOKIE = 'spotify-access-token';
const CLEAR_URL_ON_TOKEN_VALID = true;
@mbeaudru
mbeaudru / sw-test-cleaup.js
Created May 11, 2019 — forked from gauntface/sw-test-cleaup.js
Function to unregister SW and clear out old caches.
View sw-test-cleaup.js
window.__testCleanup = () => {
const unregisterSW = () => {
return navigator.serviceWorker.getRegistrations()
.then((registrations) => {
const unregisterPromise = registrations.map((registration) => {
return registration.unregister();
});
return Promise.all(unregisterPromise);
});
};
@mbeaudru
mbeaudru / PNP.md
Created Feb 22, 2019
Yarn PnP identified pain-points
View PNP.md

Yarn PnP identified pain-points

Webpack v4 only

pnp-webpack-plugin currently only supports webpack v4, so we have two options for projects (like the current storybook) to work with PnP:

  • make a PR on the pnp-webpack-plugin to add support for webpack < v4
  • update the projects relying on webpack < v4

.babelrc

@mbeaudru
mbeaudru / TodoItem.jsx
Created Aug 20, 2018
@Medium - Render Props are the new Controllers / Presentational sample
View TodoItem.jsx
import React from "react";
function TodoItem({ todo, onClick }) {
const { label } = todo;
return <li onClick={onClick}>{label}</li>;
}
export default TodoItem;
@mbeaudru
mbeaudru / TodosController.jsx
Created Aug 20, 2018
@Medium - Render Props are the new Controllers / Controller sample
View TodosController.jsx
import React, { Component, Fragment } from "react";
import PropTypes from "prop-types";
class TodosController extends Component {
state = {
todos: [
{
id: 1,
label: "First item"
},
@mbeaudru
mbeaudru / TodosContainer.jsx
Created Aug 20, 2018
@Medium - Render Props are the new Controllers / Container sample
View TodosContainer.jsx
import React, { Component, Fragment } from "react";
import TodosController from "../controllers/TodosController";
import TodoItem from "./TodoItem";
class TodosContainer extends Component {
state = {
todoInput: ""
};
updateTodoInputValue = value => this.setState({ todoInput: value });
@mbeaudru
mbeaudru / Checkbox.js
Created Mar 22, 2017
Checkbox with styled-components
View Checkbox.js
import React, { Component, PropTypes } from 'react';
import styled from 'styled-components';
class Checkbox extends Component {
render() {
return (
<Styled
onClick={() => this.props.onChange(!this.props.checked)}
>
<input
You can’t perform that action at this time.