目前,我使用React Native/Redux使用NavigationStateUtils设置了Push和Pop.但是当一个触发Push动作的按钮被多次按下时,我得到错误:should not push * route with duplicated key和*表示route.key或this.props.navKey.
可能是错误的原因是什么?我该如何使用NavigationStateUtils?为每条路线创建一个唯一的密钥?
这是我的设置 - Redux:
function mapStateToProps(state) {
return {
navigation: state.navReducer,
}
}
export default connect(
mapStateToProps,
{
pushRoute: (route) => push(route),
popRoute: () => pop(),
}
)(NavigationRoot)
Run Code Online (Sandbox Code Playgroud)
我的减速机(navReducer.js):
const initialState = {
index: 0,
key: 'root',
routes: [{
key: 'login',
title: 'Login',
component: Login,
direction: 'horizontal',
}]
}
function navigationState (state = initialState, action) {
switch(action.type) {
case PUSH_ROUTE:
if …Run Code Online (Sandbox Code Playgroud) 我在ReactJS + Redux项目中设置了MongoDB/Webpack/NodeJS Express.
我正在从redux中的动作创建者那里进行API调用,并且到达API服务器并获得成功的状态,但数据永远不会被保存,即使在终端中检查也不会创建数据库,mongo -> dbs并且它不显示practicedb我命名的数据库它作为.
可能是什么问题?我错过了什么吗?
任何指导或见解将不胜感激.谢谢
这是我为API设置的:
import axios from 'axios';
import { browserHistory } from 'react-router';
import cookie from 'react-cookie';
import { AUTH_USER, AUTH_ERROR } from './types';
const API_URL = 'http://localhost:3000/api';
export function errorHandler(dispatch, error, type) {
let errorMessage = (error.data.error) ? error.data.error : error.data;
// NOT AUTHENTICATED ERROR
if(error.status === 401) {
errorMessage = 'You are not authorized to do this.';
}
dispatch({
type: type,
payload: errorMessage
});
}
export function …Run Code Online (Sandbox Code Playgroud) 我有一个Material-UI <Table>,并且在每个<TableRow>(动态渲染)中<TableBody>,我希望<FlatButton>其中一个列有一个按钮().一旦点击按钮,它将打开一个<Dialog>内部,它希望有一个工作<Tabs>.
所以,我怎么能显示<FlatButton>每一行的特定列,并点击该按钮时,显示<Dialog>与工作一起<Tabs>在里面的内容?并有<Dialog>外线当点击关闭?
到目前为止,我有以下几点,但遇到了以下问题:打开但是很慢并且点击外面<Dialog>没有关闭它,<Tabs>可见但是它不起作用:
主表:
import React, { Component } from 'react'
import {
Subheader,
Table,
TableBody,
TableHeader,
TableHeaderColumn,
TableRow,
} from 'material-ui'
import RenderedTableRow from ‘./RenderedTableRow'
export default class MainTable extends Component {
constructor() {
super()
}
render() {
return (
<div>
<div>
<Subheader>Table</Subheader>
<Table
multiSelectable={true}
>
<TableHeader
displaySelectAll={true}
enableSelectAll={true}
>
<TableRow>
<TableHeaderColumn>
Col 1
</TableHeaderColumn> …Run Code Online (Sandbox Code Playgroud) 我目前已经设置了一个ReactJS + React Router项目,并在Chrome开发工具中的元素下方显示:
<body>
<div class="wrapper">
<div data-reactroot>
<div>
<div class="container">Center Me</div>
</div>
</div>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
带有样式,没有用于class="wrapper":
.container {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
Run Code Online (Sandbox Code Playgroud)
但是,<div class="container">Center Me</div>它停留在顶部,并且水平居中,而不是垂直居中。
我检查了该div的大小,它非常短,但占用了浏览器页面的整个宽度。
我可能做错了什么?我如何居中<div class="container">Center Me</div>?我什至试图设置100% for width and height一个更高的级别,但仍然无法正常工作。
在IOS阵营母语+终极版,我使用以下交换机组分(https://facebook.github.io/react-native/docs/switch.html).它首先设置为关闭,但是当打开时,它会立即自动关闭.可能是什么问题?
这是我的设置:
<Switch
onValueChange={this._handleSwitch}
value={switch.currentValue}
/>
Run Code Online (Sandbox Code Playgroud)
触发的动作是:
_handleSwitch(value) {
this.props.actions.triggerSwitch(value)
}
Run Code Online (Sandbox Code Playgroud)
行动是:
export function triggerSwitch(value) {
return {
type: TRIGGER_SWITCH,
currentValue: value
}
}
Run Code Online (Sandbox Code Playgroud)
在减速机中:
const initialState = {
currentValue: false
}
function switchReducer(switch = initialState, action) {
switch(action.type) {
case TRIGGER_SWITCH:
return {
currentValue: action.currentValue
}
default:
return switch
}
}
export default switchReducer
Run Code Online (Sandbox Code Playgroud)
谢谢!
在React Native和Redux中,我有一个<NavigationCardStack/>作为根组件.每次状态更新时,redux-logger都会在下一个/新状态下正确更新.
并且在状态更改之后,当新更新的状态是控制台登录子组件时,它不会控制日志记录更新的状态,而是控制台记录初始状态(在子组件childPage.js和日志记录中:) render(){ console.log(this.props.state) return(...) ....
可能是因为我错误地连接到Redux或者丢失了某些东西?因为,一切看起来都很完美,也很有意义.
先感谢您!
以下是我的代码的一些片段:
这是我的reducer,子组件只会在这里记录initialState,即使已经添加和更新了其他属性:
const initialState = {
meetUp: false,
}
function itemReducer(state = initialState, action) {
switch(action.type) {
case ITEM_QUANTITY:
return {
...state,
quantity: action.quantity
}
case ITEM_PRICE:
return {
...state,
price: action.price
}
case ITEM_MEET_UP:
return {
...state,
meetUp: action.meetUp
}
default:
return state
}
}
export default itemReducer
Run Code Online (Sandbox Code Playgroud)
并连接到根组件,如下所示:
function mapStateToProps(state) {
return {
itemInfo: state.itemReducer,
...
}
}
export default connect(
mapStateToProps,
{
itemQuantity: …Run Code Online (Sandbox Code Playgroud) 我有一个通过Heroku部署的域名,并且运行良好的www.但是,如果我没有www去域,它就无法正确呈现.我尝试在Heroku上添加两个域名,使用www和没有www,但不幸的是它仍然无效.
另外,我在这里尝试了第二步(http://documentation.unbounce.com/hc/en-us/articles/203687274-Setting-Up-Your-CNAME-with-GoDaddy-godaddy-com-)但是继续得到一个错误:An unexpected error occurred. If this issue continues, contact support.
如何向GoDaddy添加裸域以转发到我在Heroku上部署的Web,就像我的域名一样?
谢谢
编辑
目前,使用Python和Splinter,我需要准确定义option1在页面上找到选项时单击的文本:
from splinter import Browser
browser = Browser('chrome')
browser.find_option_by_text(option1).first.click()
Run Code Online (Sandbox Code Playgroud)
但如果option1不在那里,我怎么能退回并选择任何可用的下一个选项而不是必须定义它?
是否可以在页面上找到一个选项并选择遇到的任何第一个可用选项,而无需定义选项?
提前谢谢你,一定会upvote /接受答复
在我的python项目中,我使用Splinter(https://splinter.readthedocs.io/en/latest/)打开浏览器并尝试访问网站:
from splinter import Browser
browser = Browser('chrome')
browser.visit('http://www.google.com')
Run Code Online (Sandbox Code Playgroud)
并且浏览器打开了,无法访问http://www.google.com,它收到以下错误:
Traceback (most recent call last):
File "practice.py", line 90, in <module>
browser = Browser('chrome')
File "/Library/Python/2.7/site-packages/splinter/browser.py", line 63, in Browser
return driver(*args, **kwargs)
File "/Library/Python/2.7/site-packages/splinter/driver/webdriver/chrome.py", line 31, in __init__
self.driver = Chrome(chrome_options=options, **kwargs)
File "/Library/Python/2.7/site-packages/selenium-3.4.0-py2.7.egg/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "/Library/Python/2.7/site-packages/selenium-3.4.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 98, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/Library/Python/2.7/site-packages/selenium-3.4.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 185, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/Library/Python/2.7/site-packages/selenium-3.4.0-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 247, in execute
response = …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试访问虚拟机中的Amazon S3并下载文件,如下所示:
s3 = boto3.resource('s3',
aws_access_key_id="xxxxxxxxxxx",
aws_secret_access_key="xxxxxxxxxxxxxxxxx")
s3client = boto3.client('s3')
bucket = s3.Bucket('bucketone')
for obj in bucket.objects.all():
s3client.download_file(bucket_name, obj.key, filename)
Run Code Online (Sandbox Code Playgroud)
但是我得到了错误:
botocore.exceptions.ClientError:调用ListObjects操作时发生错误(InvalidAccessKeyId):您提供的AWS Access Key ID在我们的记录中不存在。
我可能做错了什么?我检查了我aws_access_key_id和aws_secret_access_key多次,但仍然得到同样的错误。本地相同的代码,但不在虚拟机上,实际上也可以在另一台计算机上工作。我必须对键进行硬编码是有原因的。
javascript ×7
reactjs ×6
html ×4
react-native ×3
redux ×3
browser ×2
python ×2
python-2.7 ×2
react-jsx ×2
splinter ×2
amazon-s3 ×1
boto ×1
boto3 ×1
cname ×1
css ×1
heroku ×1
ios ×1
material-ui ×1
mongodb ×1
node.js ×1
react-router ×1
redirect ×1
redux-thunk ×1
selenium ×1