From 16b9c41bbea985d2a3ff30d0c6a26c03bac33169 Mon Sep 17 00:00:00 2001 From: Nikolaj Frey Date: Fri, 30 Jun 2023 10:06:07 +1000 Subject: [PATCH] feat: main Attempted rolling own state --- remix/app/components/Thingtime/Thingtime.tsx | 7 +++++++ remix/app/components/Thingtime/useThingtime.tsx | 15 +++++++++++++++ remix/app/root.tsx | 2 ++ 3 files changed, 24 insertions(+) create mode 100644 remix/app/components/Thingtime/useThingtime.tsx diff --git a/remix/app/components/Thingtime/Thingtime.tsx b/remix/app/components/Thingtime/Thingtime.tsx index 1076aa3..f16b705 100644 --- a/remix/app/components/Thingtime/Thingtime.tsx +++ b/remix/app/components/Thingtime/Thingtime.tsx @@ -1,6 +1,7 @@ import React from 'react' import { Box, Flex } from '@chakra-ui/react' import { Safe } from '../Safety/Safe' +import { useThingtime } from './useThingtime' export const Thingtime = props => { // const uuid = React.useMemo(() => { @@ -8,6 +9,12 @@ export const Thingtime = props => { // }, []) const uuid = React.useRef(Math.random().toString(36).substring(7)) + const { state } = useThingtime() + + React.useEffect(() => { + console.log('nik state changed', state) + }, [state]) + const depth = React.useMemo(() => { return props?.depth || 1 }, [props?.depth]) diff --git a/remix/app/components/Thingtime/useThingtime.tsx b/remix/app/components/Thingtime/useThingtime.tsx new file mode 100644 index 0000000..63416ce --- /dev/null +++ b/remix/app/components/Thingtime/useThingtime.tsx @@ -0,0 +1,15 @@ +import React from 'react' + +const getGlobal = () => { + try { + return window + } catch { + return globalThis + } +} + +export const useThingtime = (props?: any) => { + const glob = getGlobal() + + return { state: {} } +} diff --git a/remix/app/root.tsx b/remix/app/root.tsx index 3c998fb..530f0e5 100644 --- a/remix/app/root.tsx +++ b/remix/app/root.tsx @@ -54,6 +54,8 @@ const setThingtime = glob => { try { glob.thingtime = { tmp: {}, + subscribers: {}, + state: {}, things: { db: {}, limit: 9999,