我知道manifest.json用于chrome扩展,但在这里它是其他东西.它的文件代码:
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "192x192",
"type": "image/png"
}
],
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
Run Code Online (Sandbox Code Playgroud)
当我更改某个值,页面更新,但没有任何变化.
我使用create-react-app,我想使用绝对导入./src.
正如丹·阿布拉莫夫推荐我加入.env与NODE_PATH=src和它的作品.
但我的eslint不明白该模块已经存在.我得到的错误import/no-unresolved和import/extensions
这是我的eslint-config:
module.exports = {
parser: 'babel-eslint',
extends: 'airbnb',
rules: {
'react/no-did-mount-set-state': 'off',
'import/no-extraneous-dependencies': 'off',
'no-use-before-define': 'off',
'arrow-body-style': 'off',
// uncommit on developing
'no-console': 'off',
'no-debugger': 'off',
},
globals: {
browser: true,
fetch: true,
serviceworker: true,
describe: true,
it: true,
expect: true,
document: true,
},
Run Code Online (Sandbox Code Playgroud)
};
当然,如果vscode会通过'src'为我做出建议,那将会很好.
我想使用 jest 测试我的 create-react-app。
node_modules 之一有测试错误,
但我不希望 jest 使用 node_modules 文件夹。
在文档中,我找到了配置属性“collectCoverageFrom”并尝试在我的 package.json 中使用它:
....
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom ",
"eject": "react-scripts eject"
},
"jest": {
"collectCoverageFrom": [
"!/node_modules/*"
]
}
Run Code Online (Sandbox Code Playgroud)
但什么都没有改变。
我的 gitlab ci-cd 配置文件使用许多环境变量。为了设置它们,我使用 gitlab ci-cd 秘密变量。
例如,开发部署部分:
- echo "====== Deploy to dev server ======"
# Add target server`s secret key
- apk add git openssh bash
- mkdir ~/.ssh
- echo $DEV_SERVER_SECRET_KEY_BASE_64 | base64 -d > ~/.ssh/id_rsa
- chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
- echo "Test ssh connection for"
- echo "$DEV_SERVER_USER@$DEV_SERVER_HOST"
- ssh -o StrictHostKeyChecking=no -T "$DEV_SERVER_USER@$DEV_SERVER_HOST"
# Delploy
- echo "Setup target server directories"
- TARGET_SERVER_HOST=$DEV_SERVER_HOST TARGET_SERVER_USER=$DEV_SERVER_USER TARGET_SERVER_APP_FOLDER=$DEV_SERVER_APP_FOLDER pm2 deploy pm2.config.js dev setup 2>&1 …Run Code Online (Sandbox Code Playgroud) continuous-integration continuous-deployment gitlab gitlab-ci-runner devops
我有许多包含不同查询的类型定义的文件,如下所示:
const typeDefs = gql`
type Query {
hello: String
}
`
// Provide resolver functions for your schema fields
const resolvers = {
Query: {
hello: () => 'Hello world!'
},
}
const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
export default schema
Run Code Online (Sandbox Code Playgroud)
我有很多这样的文件,后来它们被组合成一个模式。
我想为每个 typeDef 生成打字稿类型。
我找到了几种从 graphql 生成类型的解决方案,例如:https://graphql-code-generator.com
但它们都是基于将内省查询结果解析为运行 API 来工作的。
我认为,这对于我的开发过程来说非常笨重 - 必须运行类型生成,我必须事先运行服务器,我还必须添加所需的身份验证标头,尽管事实上生成完全独立于服务器,但它只取决于我声明的 typeDefs。
是否有任何工具可以将 typedef 作为参数传递给某个函数并基于它生成打字稿?
使用REST-API,我们可以进行获取查询,而不是对服务器进行查询。我使用“ Apollo-client”,但是我想创建查询而不将查询连接到组件。我可以做吗?可能我应该使用方法client.query(http://dev.apollodata.com/core/apollo-client-api.html#ApolloClient.query)和client.mutate或类似的方法?
在我的项目中,我需要在<SimpleList>组件中显示一个参考字段。
在<Datagrid>我可以做到:
<ReferenceField
label="user"
source="user_id"
reference="User"
linkType={false}
>
<TextField source="first_name" sortable={true} />
</ReferenceField>
Run Code Online (Sandbox Code Playgroud)
我如何在 SimpleList 中做同样的事情?
small={
<SimpleList
primaryText={record => record.number}
//(I want make reference here with User table
secondaryText={record => record.user_id }
/>
}
Run Code Online (Sandbox Code Playgroud) 我<Autocomplete>在Admin-on-rest 中使用组件。
<ReferenceInput label="Media" reference="Media" source="media_id" allowEmpty>
<AutocompleteInput source="name" />
</ReferenceInput>
Run Code Online (Sandbox Code Playgroud)
如果我在输入中输入一些东西,我的休息客户端会得到以下参数:
filter:{q: "1"}
Run Code Online (Sandbox Code Playgroud)
我想在名称上替换 q,与我的来源相同。我该怎么做?
javascript ×6
reactjs ×5
apollo ×3
graphql ×3
devops ×1
frontend ×1
gitlab ×1
jestjs ×1
node.js ×1
package.json ×1
react-apollo ×1
testing ×1