zustand part 3 (#2878)

* zustand part 3

* clean up

* yarn lock
This commit is contained in:
Kurt Hutten
2024-07-03 09:22:46 +10:00
committed by GitHub
parent c5150468a2
commit 4c6e8633f7
11 changed files with 81 additions and 92 deletions

View File

@ -1,4 +1,4 @@
import { FormEvent, useEffect } from 'react'
import { FormEvent, useEffect, useRef } from 'react'
import { remove } from '@tauri-apps/plugin-fs'
import {
getNextProjectIndex,
@ -39,6 +39,7 @@ import {
listProjects,
renameProjectDirectory,
} from 'lib/tauri'
import { useAppState } from 'AppState'
// This route only opens in the Tauri desktop context for now,
// as defined in Router.tsx, so we can use the Tauri APIs and types.
@ -64,6 +65,12 @@ const Home = () => {
splitKey: '|',
}
)
const ref = useRef<HTMLDivElement>(null)
const { setAppState } = useAppState()
useEffect(() => {
setAppState({ htmlRef: ref })
}, [ref])
const [state, send, actor] = useMachine(homeMachine, {
context: {
@ -198,7 +205,7 @@ const Home = () => {
}
return (
<div className="relative flex flex-col h-screen overflow-hidden">
<div className="relative flex flex-col h-screen overflow-hidden" ref={ref}>
<AppHeader showToolbar={false} />
<div className="w-full flex flex-col overflow-hidden max-w-5xl px-4 mx-auto mt-24 lg:px-2">
<section>