I\xe2\x80\x99m 在带有纱线工作区的 monorepo 上,并且 I\xe2\x80\x99m 也使用react-native-svg-transformer。\n我已将 sdk 更新到 sdk 40,并且在 Metro 中出现此错误。配置.js :\n
这是我的 Metro.config.js :
\nconst { createMetroConfiguration } = require(\'expo-yarn-workspaces\');\nconst { getDefaultConfig } = require(\'@expo/metro-config\');\nconst configuration = createMetroConfiguration(__dirname);\nmodule.exports = (async () => {\n const {\n resolver: { sourceExts },\n } = await getDefaultConfig();\n return {\n transformer: {\n babelTransformerPath: require.resolve(\'react-native-svg-transformer\'),\n },\n resolver: {\n ...configuration.resolver,\n assetExts: configuration.resolver.assetExts.filter(ext => ext !== \'svg\'),\n sourceExts: [...sourceExts, \'svg\'],\n // NOTE: using native entrypoint because bug in metro https://github.com/facebook/metro/issues/485\n resolverMainFields: [\'native\', \'module\', \'browser\', …Run Code Online (Sandbox Code Playgroud) 我尝试使用故事书文档插件,但我遇到了这个错误:
ERROR in ./node_modules/react-native/index.js 13:7
Module parse failed: Unexpected token (13:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| 'use strict';
|
Run Code Online (Sandbox Code Playgroud)
我尝试了很多方法但没有任何效果,我找不到
这里阻塞的原因是.storybook文件夹中的main.js:
const 路径 = require('路径');
module.exports = {
stories: ['../shared/**/*.stories.tsx'],
addons: [
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-knobs',
{
name: '@storybook/addon-docs',
options: {
configureJSX: true,
},
},
],
typescript: {
check: false,
checkOptions: {},
reactDocgen: 'react-docgen-typescript',
reactDocgenTypescriptOptions: {
shouldExtractLiteralValuesFromEnum: true,
propFilter: …Run Code Online (Sandbox Code Playgroud) 我在我的博览会应用程序中使用样式组件。
我需要使用这个盒子阴影:
box-shadow: 0px 6px 8px rgba(25, 50, 47, 0.08),0px 3px 4px rgba(18, 71, 52, 0.02), 0px 1px 16px rgba(18, 71, 52, 0.03);
Run Code Online (Sandbox Code Playgroud)
但是当我将它放入我的样式组件中时,如下所示:
const BackButton = styled.TouchableOpacity`
flex-direction: row;
width: 40px;
height: 40px;
align-items: center;
position: absolute;
left: ${normalize(26)}px;
justify-content: center;
padding: 0px 20px 2px;
border-radius: 12px;
background-color: ${EAppColors.BASIC_LIGHT_BLUE};
box-shadow: 0px 6px 8px rgba(25, 50, 47, 0.08),0px 3px 4px rgba(18, 71, 52, 0.02), 0px 1px 16px rgba(18, 71, 52, 0.03);
`;
Run Code Online (Sandbox Code Playgroud)
我有这个错误:
在你看来我该如何应用这个box-sahdow?
我正在尝试使用 jest-native 作为额外的匹配器,我认为我遇到了安装问题......
我正在使用 expo 的 React-native ts 应用程序,这是我的版本:
我想以这种方式使用它:
import { toHaveProp } from '@testing-library/jest-native';
expect.extend({ toHaveProp });
Run Code Online (Sandbox Code Playgroud)
但它给了我这个错误:
Module '"../../../../../../node_modules/@testing-library/jest-native/extend-expect"' has no exported member 'toHaveProp'.
Run Code Online (Sandbox Code Playgroud)
任何想法 ?
我正在第一次测试Gatsby和GraphQl,并且正在尝试一个简单的示例。
我想通过GraphQl请求在布局中显示标题时出现此错误?:未捕获的TypeError:无法读取未定义的属性“站点”
这是我的布局:
import React from 'react'
import { graphql } from 'gatsby'
export default ({ children, data }) =>
<div style={{margin: 'auto', maxWidth: 760}}>
<h2>{data.site.siteMetadata.title}</h2>
{children}
<footer>
Copyright blablb abolajoa.
</footer>
</div>
export const query = graphql`
query LayoutQuery {
site {
siteMetadata {
title
}
}
}
`
Run Code Online (Sandbox Code Playgroud)
和我的gatsby-config.js:
module.exports = {
siteMetadata: {
title: `Hardcoders`
},
plugins: [
{
resolve: 'gatsby-plugin-typography',
options: {
pathToConfigModule: 'src/utils/typography.js'
}
},
]
}
Run Code Online (Sandbox Code Playgroud)
这是项目的配置:
"dependencies": {
"gatsby": "^2.0.0",
"gatsby-plugin-typography": "^2.2.0", …Run Code Online (Sandbox Code Playgroud) 在我的 expo typescript 应用程序中,我的根组件中有一个函数:
const getCardType = (type = ECardType.WOOD) => {
setCardType(type);
};
Run Code Online (Sandbox Code Playgroud)
并将其传递到我的第一个子组件中:
<Slider data={slideData} autoPlay={false} getCardType={getCardType} />
Run Code Online (Sandbox Code Playgroud)
这是我传递函数的第一个子组件,它类型声明:
readonly getCardType?: (type: ECardType) => void;
const Slider: React.FunctionComponent<ISliderProps> = ({
data,
autoPlay,
getCardType,
})
Run Code Online (Sandbox Code Playgroud)
之后我将其传递给第二个子组件:
<SliderCardItem cardItem={item} index={index} getCardType={getCardType} />
Run Code Online (Sandbox Code Playgroud)
在这个SliderItem组件中,我使用这个函数:
useEffect(() => {
getCardType(cardType);
}, [cardType]);
Run Code Online (Sandbox Code Playgroud)
但出现 TS 错误: 无法调用子组件中可能“未定义”的对象
我在onPress()中设置了下面的cardType
我仅在此组件中出现此错误
有解决此错误的想法吗?
javascript ×5
react-native ×4
expo ×2
reactjs ×2
typescript ×2
css ×1
gatsby ×1
graphql ×1
graphql-js ×1
jestjs ×1
react-native-testing-library ×1
storybook ×1
undefined ×1
webpack ×1