client: remove preact to fix file dropdown process crash

This commit is contained in:
Max Leiter 2022-04-10 20:05:42 -07:00
parent 401a0df63b
commit 83def0ec86
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA
5 changed files with 48 additions and 63 deletions

View file

@ -25,14 +25,8 @@ const FileDropdown = ({
setExpanded(next)
}
const onOpen = useCallback(() => {
setExpanded(true)
}, [])
const onClose = useCallback(() => {
setExpanded(false)
// contentRef.current?.focus()
}, [])
const onOpen = () => setExpanded(true)
const onClose = useCallback(() => setExpanded(false), [setExpanded])
useEffect(() => {
const newItems = files.map((file) => {
@ -52,25 +46,21 @@ const FileDropdown = ({
setItems(newItems)
}, [files])
const content = useCallback(
() => (
<ul className={styles.content}>
{items.map((item) => (
<li key={item.id} onClick={onClose}>
<a href={`#${item.title}`}>
<ShiftBy y={5}>
<span className={styles.fileIcon}>{item.icon}</span>
</ShiftBy>
<span className={styles.fileTitle}>
{item.title ? item.title : "Untitled"}
</span>
</a>
</li>
))}
</ul>
),
[items, onClose]
)
const content =
<ul className={styles.content}>
{items.map((item) => (
<li key={item.id} onClick={onClose}>
<a href={`#${item.title}`}>
<ShiftBy y={5}>
<span className={styles.fileIcon}>{item.icon}</span>
</ShiftBy>
<span className={styles.fileTitle}>
{item.title ? item.title : "Untitled"}
</span>
</a>
</li>
))}
</ul>
// a list of files with an icon and a title
return (

View file

@ -172,7 +172,7 @@ const Post = ({
}
const submitPassword = useCallback(
(password) => onSubmit("protected", password),
(password: string) => onSubmit("protected", password),
[onSubmit]
)

View file

@ -5,35 +5,36 @@ dotenv.config()
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
experimental: {
outputStandalone: true,
esmExternals: true
},
webpack: (config, { dev, isServer }) => {
if (!dev && !isServer) {
Object.assign(config.resolve.alias, {
react: "preact/compat",
"react-dom/test-utils": "preact/test-utils",
"react-dom": "preact/compat"
})
}
return config
},
async rewrites() {
return [
{
source: "/server-api/:path*",
destination: `${process.env.API_URL}/:path*`
},
{
source: "/file/raw/:id",
destination: `/api/raw/:id`
}
]
}
reactStrictMode: true,
experimental: {
outputStandalone: true,
esmExternals: true
},
webpack: (config, { dev, isServer }) => {
if (!dev && !isServer) {
// TODO: enabling Preact causes the file switcher to hang the browser process
// Object.assign(config.resolve.alias, {
// react: "preact/compat",
// "react-dom/test-utils": "preact/test-utils",
// "react-dom": "preact/compat"
// })
}
return config
},
async rewrites() {
return [
{
source: "/server-api/:path*",
destination: `${process.env.API_URL}/:path*`
},
{
source: "/file/raw/:id",
destination: `/api/raw/:id`
}
]
}
}
export default bundleAnalyzer({ enabled: process.env.ANALYZE === "true" })(
nextConfig
nextConfig
)

View file

@ -5,7 +5,7 @@
"scripts": {
"dev": "next dev --port 3001",
"build": "next build",
"start": "next start",
"start": "next start --port 3001",
"lint": "next lint && prettier --list-different --config .prettierrc '{components,lib,pages}/**/*.{ts,tsx}' --write",
"analyze": "cross-env ANALYZE=true next build",
"find:unused": "next-unused"
@ -27,7 +27,6 @@
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-hover-media-feature": "^1.0.2",
"postcss-preset-env": "^7.4.3",
"preact": "^10.6.6",
"prism-react-renderer": "^1.3.1",
"react": "17.0.2",
"react-datepicker": "^4.7.0",

View file

@ -3524,11 +3524,6 @@ postcss@^8.1.7, postcss@^8.3.0, postcss@^8.4.12:
picocolors "^1.0.0"
source-map-js "^1.0.2"
preact@^10.6.6:
version "10.6.6"
resolved "https://registry.yarnpkg.com/preact/-/preact-10.6.6.tgz#f1899bc8dab7c0788b858481532cb3b5d764a520"
integrity sha512-dgxpTFV2vs4vizwKohYKkk7g7rmp1wOOcfd4Tz3IB3Wi+ivZzsn/SpeKJhRENSE+n8sUfsAl4S3HiCVT923ABw==
precinct@^7.0.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/precinct/-/precinct-7.1.0.tgz#a0311e0b59029647eaf57c2d30b8efa9c85d129a"