我将通过这些信息:https: //facebook.github.io/react-native/docs/running-on-device-ios.html#content
我做了react-native bundle
命令,改变了AppDelegate.m
,我可以成功建立.虽然我不确定它最终构建的位置.放置.app文件在哪里,当我想将.app文件复制到我的手机时,我应该通过iTunes进行同步,还是有更快的方法?
基本上我只是想创建和部署一个不需要React打包器服务器的独立应用程序.
我正在努力使用户可以将图标从Web浏览器拖到他们的桌面,并创建一个文本文件.我有内容部分,但我无法弄清楚如何设置文件名.我试过变异,dataTransfer.files
但这是只读的.我不知道如何实现这一目标.
class CrashReport extends React.Component {
dragStart(event) {
const dat = {name: 'test!', crashDate: new Date()};
event.dataTransfer.name = 'tmp.txt'; // bad
event.dataTransfer.setData('text/plain', JSON.stringify(dat, null, 2));
console.log(event.dataTransfer);
}
render() {
return <div draggable onDragStart={this.dragStart.bind(this)}>
Drag This
</div>
}
}
Run Code Online (Sandbox Code Playgroud)
我完全陷入了阿波罗问题,为此我打开了一个GitHub问题并且没有响应.
我正在使用阿波罗变种optimisticResponse
.根据我的理解,它应该工作的方式是update()
两次调用:首先使用乐观数据,然后再使用来自网络的实际数据.
但由于某种原因,我的代码不是这样的.我接到两个update()
电话,都有乐观的数据.
这是一个演示此行为的回购:https://github.com/ffxsam/apollo-update-bug
说我有以下几点:
interface Validator {
validate: (value: string) => boolean;
errorMessage: string;
}
interface EditDialogField {
label: string;
prop: string;
required?: boolean;
type: 'input';
validators?: Validator[];
}
Run Code Online (Sandbox Code Playgroud)
这很有用,因为当我使用这些界面时 IntelliSense 会弹出建议,但我希望能够添加也显示在 IntelliSense 中的注释(特别是 VS Code)。这可能吗?
我花了很多时间考虑如何在React中尽可能干净地构建最好的东西.最近我一直在讨论React容器是否应该做什么,除了连接到Redux(或其他数据 - 流星)并渲染/返回单个组件,或者容器是否也应该负责事件处理.例如,这是两个模型之间的折腾:
// ThingContainer.js
import Thing from '../components/Thing';
export default someHigherOrderFunc(/* map state/data to props */)(Thing)
// Thing.js
export default class Thing extends Component {
handleClick() { /* ... */ }
handleMouseEnter() { /* ... */ }
render() {
// Other components rendered here, both container or presentational
}
}
Run Code Online (Sandbox Code Playgroud)
// ThingContainer.js
class ThingContainer extends Component {
handleClick() { /* ... */ }
handleMouseEnter() { /* ... */ }
render() {
// Now Thing can be stateless …
Run Code Online (Sandbox Code Playgroud) 这两个陈述之间究竟有什么区别?
funcThatReturnsAPromise()
.then(() => { /* success */ })
.catch(() => { /* fail */ });
funcThatReturnsAPromise()
.then(() => { /* success */ }, () => { /* fail */ });
Run Code Online (Sandbox Code Playgroud) 使用时mapGetters
,TypeScript无法查看绑定到Vue组件的getter的内容,因此会抛出错误.例:
import Vue from 'vue';
import { mapActions, mapGetters } from 'vuex';
export default Vue.extend({
computed: {
...mapGetters('ui', ['navCollapsed']),
minimizerIconClass(): string {
return `fa${this.navCollapsed ? '' : 'r'} fa-window-maximize`;
},
},
Run Code Online (Sandbox Code Playgroud)
TypeScript大喊大叫this.navCollapsed
:
TS2339: Property 'navCollapsed' does not exist on type 'CombinedVueInstance<Vue, {}, { openMobileMenu(): void; }, { minimizerIconClass: string; }, Readon...'.
Run Code Online (Sandbox Code Playgroud)
我该如何解决?我能想到的唯一解决方法是不使用mapGetters()
.
我有一个新的基于vue-cli 3的项目,其中包含.graphql
文件src/
夹中的文件,例如:
#import "./track-list-fragment.graphql"
query ListTracks(
$sortBy: String
$order: String
$limit: Int
$nextToken: String
) {
listTracks(
sortBy: $sortBy
order: $order
limit: $limit
nextToken: $nextToken
) {
items {
...TrackListDetails
}
nextToken
}
}
Run Code Online (Sandbox Code Playgroud)
当我跑步时yarn serve
,它抱怨没有GraphQL的加载器:
Module parse failed: Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
> #import "./track-list-fragment.graphql"
|
| query ListTracks(
Run Code Online (Sandbox Code Playgroud)
但我确实vue.config.js
正确设置了(我认为):
const webpack = require('webpack');
const path = require('path');
module.exports = …
Run Code Online (Sandbox Code Playgroud) 我有一个OAuth进程弹出一个窗口,但是当我登录时,重定向到OAuth回调页面发生在弹出窗口而不是父窗口(window.opener
).这可能有点hacky,但我想让弹出窗口告诉父母"我们被授权!".
这实际上有效:
OAuthCallback = React.createClass({
displayName: 'OAuthCallback',
render() {
window.opener.console.log('hello parent window');
return (
<div>
Hi, OAuth is process is done.
</div>
)
}
});
Run Code Online (Sandbox Code Playgroud)
但我想知道是否有某种方法可以让弹出窗口告诉父窗口调用prop函数,例如this.props.oauthSucceeded()
.
我想我知道答案,但只是为了确保:
我希望this.setState()
在Redux状态更改为某个条件(例如state.dataLoaded === true
)时调用React组件.我应该以某种方式使用subscribe
,或者是太低级别我应该使用connect
将状态映射到道具?在这种情况下,我认为这样的事情是可以接受的:
componentWillReceiveProps(nextProps) {
if (nextProps.dataLoaded) {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(nextProps.posts)
});
}
}
Run Code Online (Sandbox Code Playgroud) reactjs ×4
javascript ×3
vue.js ×3
graphql ×2
redux ×2
typescript ×2
apollo ×1
aws-appsync ×1
intellisense ×1
ios ×1
promise ×1
react-native ×1
vue-apollo ×1
vue-cli ×1
vuex ×1
webpack ×1