Last active
March 19, 2019 00:23
-
-
Save ajcrites/63eb2f1c394df5447fc4056156f4ceed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, createContext } from 'react'; | |
| import { HexInput } from '~/HexInput'; | |
| import { RgbaInput } from '~/RgbaInput'; | |
| interface ColorContextProps { | |
| hex: string; | |
| rgba: number[]; | |
| setHex: (value) => void; | |
| setRgba: (value) => void; | |
| }; | |
| export const ColorContext = createContext<ColorContextProps>({} as any); | |
| export const ColorToolApp = () => { | |
| const [hex, setHex] = useState(''); | |
| const [rgba, setRgba] = useState(['', '', '', '']); | |
| const state: ColorContextProps = { | |
| hex, rgba, setHex, setRgba, | |
| }; | |
| return ( | |
| <main> | |
| <ColorContext.Provider value={state}> | |
| <HexInput /> | |
| <RgbaInput /> | |
| </ColorContext.Provider> | |
| </main> | |
| ); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment