我的middleware.js
文件位于/myproject/pages/middleware.js
:
export function middleware(request) {
console.log(1)
return NextResponse.redirect(new URL('/', request.url))
}
// See "Matching Paths" below to learn more
export const config = {
matcher: ['/test'],
}
Run Code Online (Sandbox Code Playgroud)
现在我期望的是,当我进入该页面/test
时,它应该将我重定向到/
. 然而什么也没发生,我看到了我的标准 404 页面。
有什么想法吗?
NextJs版本:12.2.2
我正在使用<Mutation />
具有Render Prop API的组件并尝试在UI中执行乐观响应.
到目前为止,我在_onSubmit
功能中有这个块-
createApp({
variables: { id: uuid(), name, link },
optimisticResponse: {
__typename: "Mutation",
createApp: {
__typename: "App",
id: negativeRandom(),
name,
link
}
}
});
Run Code Online (Sandbox Code Playgroud)
我的<Mutation />
组件看起来像 -
<Mutation
mutation={CREATE_APP}
update={(cache, { data: { createApp } }) => {
const data = cache.readQuery({ query: LIST_APPS });
if (typeof createApp.id == "number") {
data.listApps.items.push(createApp);
cache.writeQuery({
query: LIST_APPS,
data
});
}
}}
>
{/*
some code here
*/}
</Mutation>
Run Code Online (Sandbox Code Playgroud)
我知道该update
函数在<Mutation …
我可以想到使用Native Navigation的唯一原因是当我有更多的屏幕和基于JS的解决方案(如React Navigation)将所有屏幕保留在内存中.现在我不是本地开发人员,所以上面的内容可能很模糊.
reactjs react-native react-native-navigation react-navigation wixcode
假设我有2个文件夹- 苹果和橘子
现在,我使用VSCode 打开了苹果code apple
。
在VSCode的嵌入式终端中,如何通过覆盖它而不启动新实例的方式在与Apple相同的实例中打开橙色文件夹?
我正在使用 Node.js 10.0.0 & 我的index.mjs
样子:
import path from "path";
console.log(__dirname);
Run Code Online (Sandbox Code Playgroud)
在我的终端中,我运行
node --experimental-modules index.mjs
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
(node:3750) ExperimentalWarning: The ESM module loader is experimental.
ReferenceError: __dirname is not defined
at file:///MyFolderPath/node-10/index.mjs:3:21
at ModuleJob.run (internal/modules/esm/module_job.js:106:14)
Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个esbuild
使用 Sharp 将 GIF 转换为 PNG 的插件,但出现以下错误:
\n\n\xe2\x9d\xaf npx esbuild .\\src\\utils\\gif-to-png.ts --platform=node --bundle\nnode_modules/sharp/lib/utility.js:7:22:错误:否加载器配置为“.node”文件:node_modules/sharp/build/Release/sharp.node\n7 \xe2\x94\x82 const Sharp = require(\'../build/Release/sharp.node\'); \n\xe2\x95\xb5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\n
import fs from \'fs\'\nimport path from \'path\'\nimport sharp from \'sharp\'\nimport { Plugin } from \'esbuild\'\n\nconst ROOT_PATH = process.cwd()\nconst POSTS_PATH = path.join(ROOT_PATH, \'public\')\n\nfunction* walkSync(dir: fs.PathLike): any {\n const files = fs.readdirSync(dir, { withFileTypes: true })\n for (let i = 0; i < files.length; i++) {\n if (files[i].isDirectory()) {\n yield* walkSync(path.join(dir as …
Run Code Online (Sandbox Code Playgroud) 我同意Apollo Client很难设置,因为它有很多样板(尽管在阅读文档之后变得很简单)和诸如AWS Amplify,URQL,Apollo Boost和Micro GraphQL React之类的东西使得在客户端上使用GraphQL变得容易.
我目前正在使用AWS AppSync并希望在AWS Amplify和Apollo Client之间做出选择,而我正考虑进入所有AWS.
那么AWS Amplify和Apollo Client有什么区别?
基本上,我只用constructor
了React
3个原因-
state
-class App extends React.Component {
constructor(props) {
super(props);
this.state = { counter: 0 };
}
}
Run Code Online (Sandbox Code Playgroud)
但是由于Babel的班级领域支持,我不再使用它
class App extends React.Component {
state = { counter: 0 };
}
Run Code Online (Sandbox Code Playgroud)
bind
像-class App extends React.Component {
constructor(props) {
super(props);
this.increment.bind(this);
}
increment() {
}
}
Run Code Online (Sandbox Code Playgroud)
但是由于arrow
功能原因,我不再这样做了
class App extends React.Component {
increment = () => {
}
}
Run Code Online (Sandbox Code Playgroud)
createRef
-class App extends React.Component {
constructor(props) …
Run Code Online (Sandbox Code Playgroud) 我想从生成的捆绑包中树摇动lodash
以及我未使用的multiply
功能webpack
我有2个主要文件app.js
&math.js
它包含以下代码 -
import map from "lodash/map";
import { sum } from "./math";
console.log("");
console.log(`2 + 3 = ${sum(2, 3)}`);
map([1, 2, 3], x => {
console.log(x);
});
Run Code Online (Sandbox Code Playgroud)
export const sum = (a, b) => a + b;
export const multiply = (m, n) => m * n;
Run Code Online (Sandbox Code Playgroud)
const path = require("path");
const webpack = require("webpack");
const UglifyJSPlugin = require("uglifyjs-webpack-plugin");
const Jarvis = require("webpack-jarvis");
let plugins = [new …
Run Code Online (Sandbox Code Playgroud) 我想创建以下效果:
目前,我有这个奇怪的效果:
我使用转型从@headlessui/react
。
我的代码看起来像:
<Transition
show={app.theme !== 'light'}
enter="transition ease duration-700 transform"
enterFrom="opacity-0 -translate-y-full"
enterTo="opacity-100 translate-y-0"
leave="transition ease duration-1000 transform"
leaveFrom="opacity-100 translate-y-0"
leaveTo="opacity-0 -translate-y-full"
>
Run Code Online (Sandbox Code Playgroud)
我如何实现它?
reactjs ×5
javascript ×4
graphql ×2
node.js ×2
apollo ×1
aws-amplify ×1
aws-appsync ×1
esbuild ×1
html ×1
macos ×1
next.js ×1
react-apollo ×1
react-native ×1
ref ×1
sharp ×1
tailwind-css ×1
terminal ×1
uglifyjs ×1
uglifyjs2 ×1
webpack ×1
webpack-2 ×1
windows ×1
wixcode ×1