我使用的是 iOS 13.5 并使用 Xcode 11.4 来构建它。我收到此错误消息:
这KBlackberry
是我的 iPhone 设备名称。
我尝试重新启动设备并重新连接,当然还有其他各种事情,但似乎没有任何解决方法。我的下一步是尝试更新版本的 Xcode。
我想知道是否有一种更好的方式来有条件地传递道具而不是使用if语句.
例如,我现在有:
var parent = React.createClass({
propTypes: {
editable: React.PropTypes.bool.isRequired,
editableOpts: React.PropTypes.shape({...})
},
render: function() {
if(this.props.editable) {
return (
<Child editable={this.props.editableOpts} />
);
} else {
// In this case, Child will use the editableOpts from its own getDefaultProps()
return (
<Child />
);
}
}
});
Run Code Online (Sandbox Code Playgroud)
有没有办法在没有if语句的情况下编写这个?我正在考虑JSX中的一种inline-if语句:
var parent = React.createClass({
propTypes: {
editable: React.PropTypes.bool.isRequired,
editableOpts: React.PropTypes.shape({...})
},
render: function() {
return (
<Child
{this.props.editable ? editable={this.props.editableOpts} : null}
/>
);
}
});
Run Code Online (Sandbox Code Playgroud)
总结:我正试图找到一种方法来定义一个道具Child
,但是传递一个值(或做一些其他的),这样Child …
运行我的应用程序后出现此错误:
错误:捆绑失败:错误:无法
react-native-safe-area-context
从node_modules/react-navigation-stack/lib/module/vendor/views/Stack/StackView.js
以下位置解析模块:在项目中找不到 react-native-safe-area-context。
但是我为我的旧演示所做的同样的事情。它工作得很好。
我不知道我在这里做错了什么。请检查我的代码:
用于安装:
npm install --save react-navigation
npm install --save react-native-gesture-handler
npm install --save react-navigation-stack
应用程序.js
import { createAppContainer } from "react-navigation";
import { createStackNavigator } from "react-navigation-stack";
import FirstOptionsPage from "./FirstOptionsPage";
const MainNavigator = createStackNavigator(
{
FirstOptions: FirstOptionsPage
},
{
defaultNavigationOptions: {
headerStyle: {
// backgroundColor: '#28F1A6',
elevation: 0,
shadowOpacity: 0
},
headerTintColor: "#ca375e",
headerTitleStyle: {
fontWeight: "bold",
color: "#161616"
}
}
}
);
const App = createAppContainer(MainNavigator); // For …
Run Code Online (Sandbox Code Playgroud) react-native react-native-android react-native-ios react-native-navigation
首先我初始化 i18next inctance
\nimport i18n from 'i18next';\nimport { initReactI18next } from 'react-i18next';\n\nconst resources = {\n en: {\n translation: {\n 'Welcome to React': 'Welcome to React and react'\n }\n },\n de: {\n translation: {\n 'Welcome to React': 'Bienvenue \xc3\xa0 React et react-i18next'\n }\n }\n};\n\ni18n.use(initReactI18next).init({\n resources,\n lng: 'de',\n\n interpolation: {\n escapeValue: false\n }\n});\n\nexport default i18n;\n
Run Code Online (Sandbox Code Playgroud)\n然后我在组件中使用带有 useTranslation 挂钩的实例
\nimport React from 'react'\nimport { useTranslation } from 'react-i18next'\n\nimport classes from './intro.module.scss'\n\nexport default function Intro() {\n const { t, i18n } …
Run Code Online (Sandbox Code Playgroud) 奇怪的react-native-vector-icons
是,它运行良好,但在新^
版本的package.json
文件中使用("^6.6.0") 作为其版本会发生此错误。
这很奇怪,因为两天前它运行良好,但现在我的项目开始时遇到了这个错误:
错误:错误:无法
@react-native-community/toolbar-android
从node_modules\react-native-vector-icons\lib\toolbar-android.js
以下位置解析模块:在项目中找不到@react-native-community/toolbar-android。
javascript reactjs android-toolbar react-native react-native-vector-icons
我开始摆弄 Next JS,并且遇到了第一个障碍。我正在创建一个显示一堆播客剧集的页面,并在主页上为每个播客显示一个小预览卡。卡组件看起来像这样:
import React from 'react';
import Link from 'next/link';
import { kebabCase } from 'lodash';
import { format } from 'date-fns';
import TextTruncate from 'react-text-truncate';
import { Episode as EpisodeInterface } from '../../interfaces';
type Props = {
episode: EpisodeInterface;
};
const Episode: React.FunctionComponent<Props> = ({ episode }) => {
return (
<Link
href="episodes/[id]"
as={`episodes/${episode.itunes.episode}-${kebabCase(episode.title)}`}
>
<div className="group transition duration-500 cursor-pointer rounded-lg overflow-hidden shadow-lg border border-cream-darker bg-surface hover:bg-surface-hover hover:border-surface-hover hover:text-text-hover">
<div className="px-6 py-6">
<div className="font-bold font-serif text-3xl mb-2">
{episode.title} …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个Electron JS应用程序,其目的是打印字母大小的PDF.
这是我的打印代码片段:
win = new BrowserWindow({
width: 378,
height: 566,
show: true,
webPreferences: {
webSecurity: false,
plugins: true
}
});
// load PDF
win.loadURL('file://' + __dirname + '/header1_X_BTR.pdf');
// if pdf is loaded start printing
win.webContents.on('did-finish-load', () => {
win.webContents.print({silent: true, printBackground:true});
});
Run Code Online (Sandbox Code Playgroud)
我的问题是:如果我让print({silent:true})
我的打印机打印一个空页面.如果有print({silent:false})
,打印机的打印方式与屏幕截图相同,包括标题,控件等.
我需要对PDF内容进行静音打印,而且我无法在数天内完成这项工作.有没有人与Electron有同样的经历?
我经常研究一些JavaScript
面试问题,突然间我看到一个关于使用reduce
函数进行排序的问题Array
,我在MDN中读到了它并在一些medium
文章中使用它,但排序Array
是如此创新:
const arr = [91,4,6,24,8,7,59,3,13,0,11,98,54,23,52,87,4];
Run Code Online (Sandbox Code Playgroud)
我想了很多,但我不知道如何回答这个问题,这个reduce
call back
功能一定是怎么回事?是什么initialValue
的reduce
功能?什么是accumulator
和currentValue
的call back
功能reduce
?
最后,这种方式是否比其他排序算法有一些好处?或者改进其他算法是否有用?
我以这种方式在我的反应应用程序中使用反应查询
const { data, status } = useQuery(key, queryFunc, { staleTime: 1 * 60 * 1000 });
Run Code Online (Sandbox Code Playgroud)
我希望能够根据数据值使缓存中的某个键无效,基本上是当数据为空时,所以我添加了一个效果
useEffect(() => {
if (data === null) {
queryClient. invalidateQueries(key)
}
}, [data])
Run Code Online (Sandbox Code Playgroud)
这种方法将导致请求循环,其中无效的查询将重新获取,获取 null 作为响应,效果执行并无效等等......
我希望能够从缓存中删除密钥而不需要重新获取,所以我不会陷入这个无限请求循环,一直在深入研究反应查询文档,但没有运气。无论如何,反应查询也有类似的情况,其中密钥需要从缓存中删除而不重新获取?
在 Next.js 中尝试使用动态路由进行浅层路由时,页面被刷新并被忽略。似乎很多人对此感到困惑。
假设我们从下一页开始
router.push(
'/post/[...slug]',
'/post/2020/01/01/hello-world',
{ shallow: true }
);
Run Code Online (Sandbox Code Playgroud)
然后我们转到另一篇博文:
router.push(
'/post/[...slug]',
'/post/2020/01/01/foo-bar',
{ shallow: true }
);
Run Code Online (Sandbox Code Playgroud)
这个不会触发浅层路由,浏览器刷新,为什么?
在代码库中很清楚这是一个特性:
// If asked to change the current URL we should reload the current page
// (not location.reload() but reload getInitialProps and other Next.js stuffs)
// We also need to set the method = replaceState always
// as this should not go into the history (That's how browsers work)
// We should compare the new asPath to the …
Run Code Online (Sandbox Code Playgroud)