client: remove preact to fix file dropdown process crash
This commit is contained in:
parent
401a0df63b
commit
83def0ec86
5 changed files with 48 additions and 63 deletions
|
@ -25,14 +25,8 @@ const FileDropdown = ({
|
||||||
setExpanded(next)
|
setExpanded(next)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onOpen = useCallback(() => {
|
const onOpen = () => setExpanded(true)
|
||||||
setExpanded(true)
|
const onClose = useCallback(() => setExpanded(false), [setExpanded])
|
||||||
}, [])
|
|
||||||
|
|
||||||
const onClose = useCallback(() => {
|
|
||||||
setExpanded(false)
|
|
||||||
// contentRef.current?.focus()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const newItems = files.map((file) => {
|
const newItems = files.map((file) => {
|
||||||
|
@ -52,25 +46,21 @@ const FileDropdown = ({
|
||||||
setItems(newItems)
|
setItems(newItems)
|
||||||
}, [files])
|
}, [files])
|
||||||
|
|
||||||
const content = useCallback(
|
const content =
|
||||||
() => (
|
<ul className={styles.content}>
|
||||||
<ul className={styles.content}>
|
{items.map((item) => (
|
||||||
{items.map((item) => (
|
<li key={item.id} onClick={onClose}>
|
||||||
<li key={item.id} onClick={onClose}>
|
<a href={`#${item.title}`}>
|
||||||
<a href={`#${item.title}`}>
|
<ShiftBy y={5}>
|
||||||
<ShiftBy y={5}>
|
<span className={styles.fileIcon}>{item.icon}</span>
|
||||||
<span className={styles.fileIcon}>{item.icon}</span>
|
</ShiftBy>
|
||||||
</ShiftBy>
|
<span className={styles.fileTitle}>
|
||||||
<span className={styles.fileTitle}>
|
{item.title ? item.title : "Untitled"}
|
||||||
{item.title ? item.title : "Untitled"}
|
</span>
|
||||||
</span>
|
</a>
|
||||||
</a>
|
</li>
|
||||||
</li>
|
))}
|
||||||
))}
|
</ul>
|
||||||
</ul>
|
|
||||||
),
|
|
||||||
[items, onClose]
|
|
||||||
)
|
|
||||||
|
|
||||||
// a list of files with an icon and a title
|
// a list of files with an icon and a title
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -172,7 +172,7 @@ const Post = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitPassword = useCallback(
|
const submitPassword = useCallback(
|
||||||
(password) => onSubmit("protected", password),
|
(password: string) => onSubmit("protected", password),
|
||||||
[onSubmit]
|
[onSubmit]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -5,35 +5,36 @@ dotenv.config()
|
||||||
|
|
||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
experimental: {
|
experimental: {
|
||||||
outputStandalone: true,
|
outputStandalone: true,
|
||||||
esmExternals: true
|
esmExternals: true
|
||||||
},
|
},
|
||||||
webpack: (config, { dev, isServer }) => {
|
webpack: (config, { dev, isServer }) => {
|
||||||
if (!dev && !isServer) {
|
if (!dev && !isServer) {
|
||||||
Object.assign(config.resolve.alias, {
|
// TODO: enabling Preact causes the file switcher to hang the browser process
|
||||||
react: "preact/compat",
|
// Object.assign(config.resolve.alias, {
|
||||||
"react-dom/test-utils": "preact/test-utils",
|
// react: "preact/compat",
|
||||||
"react-dom": "preact/compat"
|
// "react-dom/test-utils": "preact/test-utils",
|
||||||
})
|
// "react-dom": "preact/compat"
|
||||||
}
|
// })
|
||||||
return config
|
}
|
||||||
},
|
return config
|
||||||
async rewrites() {
|
},
|
||||||
return [
|
async rewrites() {
|
||||||
{
|
return [
|
||||||
source: "/server-api/:path*",
|
{
|
||||||
destination: `${process.env.API_URL}/:path*`
|
source: "/server-api/:path*",
|
||||||
},
|
destination: `${process.env.API_URL}/:path*`
|
||||||
{
|
},
|
||||||
source: "/file/raw/:id",
|
{
|
||||||
destination: `/api/raw/:id`
|
source: "/file/raw/:id",
|
||||||
}
|
destination: `/api/raw/:id`
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default bundleAnalyzer({ enabled: process.env.ANALYZE === "true" })(
|
export default bundleAnalyzer({ enabled: process.env.ANALYZE === "true" })(
|
||||||
nextConfig
|
nextConfig
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev --port 3001",
|
"dev": "next dev --port 3001",
|
||||||
"build": "next build",
|
"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",
|
"lint": "next lint && prettier --list-different --config .prettierrc '{components,lib,pages}/**/*.{ts,tsx}' --write",
|
||||||
"analyze": "cross-env ANALYZE=true next build",
|
"analyze": "cross-env ANALYZE=true next build",
|
||||||
"find:unused": "next-unused"
|
"find:unused": "next-unused"
|
||||||
|
@ -27,7 +27,6 @@
|
||||||
"postcss-flexbugs-fixes": "^5.0.2",
|
"postcss-flexbugs-fixes": "^5.0.2",
|
||||||
"postcss-hover-media-feature": "^1.0.2",
|
"postcss-hover-media-feature": "^1.0.2",
|
||||||
"postcss-preset-env": "^7.4.3",
|
"postcss-preset-env": "^7.4.3",
|
||||||
"preact": "^10.6.6",
|
|
||||||
"prism-react-renderer": "^1.3.1",
|
"prism-react-renderer": "^1.3.1",
|
||||||
"react": "17.0.2",
|
"react": "17.0.2",
|
||||||
"react-datepicker": "^4.7.0",
|
"react-datepicker": "^4.7.0",
|
||||||
|
|
|
@ -3524,11 +3524,6 @@ postcss@^8.1.7, postcss@^8.3.0, postcss@^8.4.12:
|
||||||
picocolors "^1.0.0"
|
picocolors "^1.0.0"
|
||||||
source-map-js "^1.0.2"
|
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:
|
precinct@^7.0.0:
|
||||||
version "7.1.0"
|
version "7.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/precinct/-/precinct-7.1.0.tgz#a0311e0b59029647eaf57c2d30b8efa9c85d129a"
|
resolved "https://registry.yarnpkg.com/precinct/-/precinct-7.1.0.tgz#a0311e0b59029647eaf57c2d30b8efa9c85d129a"
|
||||||
|
|
Loading…
Reference in a new issue