Skip to content

Instantly share code, notes, and snippets.

// HOC using Class Component
function Wrap(WrappedComponent) {
return class extends React.Component {
render() {
// Copy the props so we don't mutate the original component
const newProps = {...this.props};
// Loop through the props and check if the props ia a number
for (let [key, value] of Object.entries(newProps)) {
if (typeof value === "number") {
// Increase the prop
import React from 'react';
import { Provider1, Provider2, Provider3 } from './';
function ProviderComposer({ contexts, children }) {
return contexts.reduceRight(
// kids = accumulator, parent = currentValue
(kids, parent) =>
React.cloneElement(parent, {
children: kids
}),
// Actual Code
constructor() {
super();
this.state = {
name: "",
email: "",
password: "",
password2: "",
errors: {}
};