Skip to content

Instantly share code, notes, and snippets.

View chriskavanagh's full-sized avatar

Chris Kavanagh chriskavanagh

  • Home Office
  • Roanoke, VA - U.S.A.
View GitHub Profile
import React from "react";
import { Formik, Field, ErrorMessage, Form } from "formik";
import * as Yup from "yup";
//import Error from "./Error";
import styled from "styled-components";
const Button = styled.button`
background: gray;
color: navy;
width: 30%;
import React from "react";
import { Formik } from "formik";
import * as Yup from "yup";
//import Error from "./Error";
import styled from "styled-components";
const Form = styled.form`
width: 100%;
max-width: 600px;
margin: 25px auto;
@chriskavanagh
chriskavanagh / react-context.txt
Last active February 20, 2024 02:11
react context
import { useState, createContext, useContext } from "react";
const CounterContext = createContext(null);
const CounterContextProvider = ({ children }) => (
<CounterContext.Provider value={useState(0)}>
{children}
</CounterContext.Provider>
);
@chriskavanagh
chriskavanagh / compositionContext.txt
Last active February 20, 2024 02:09
composition instead of context
import { useState } from "react";
const Container = ({ children }) => <div>{children}</div>;
const AddOneButton = ({ setCounter }) => (
<div>
<button onClick={() => setCounter((v) => v + 1)}>Add One</button>
</div>
);