Skip to content

Instantly share code, notes, and snippets.

View wookieb's full-sized avatar

Łukasz Kużyński wookieb

View GitHub Profile
@wookieb
wookieb / toggle.jsx
Last active March 15, 2022 09:40
useControlledState
import {useControlledState} from "@react-stately/utils";
export function Toggle({open, defaultOpen, onOpenChange, children, ...props}) {
// you don't need to manually handle open, defaultOpen and onOpenChange
// just forward them to hook
const [isOpen, setIsOpen] = useControlledState(open, defaultOpen, onOpenChange);
return <div {...props}>
<button onClick={() => {
// this will call `onOpenChange` on click so you don't have to do it
function isComplete(data: any): data is {x: number, y: number, size: number, metadata: any} {
return typeof data.x === 'number' && typeof data.y === 'number' && typeof data.size === 'number';
}
data.reduce((result, data) => {
if (isComplete(data)) {
// w tym miejscu ts wie, że "data" ma kształt z type guarda
return result.concat([
getColor(data.x, data.y, data.metadata)
])
@wookieb
wookieb / keybase.md
Created April 11, 2014 19:06
keybase.md

Keybase proof

I hereby claim:

  • I am wookieb on github.
  • I am wookieb (https://keybase.io/wookieb) on keybase.
  • I have a public key whose fingerprint is 5FD8 E95E F242 27B6 2080 908E 20CA 5AAB B22F 596E

To claim this, I am signing this object: