【javascript – 使用ReactJS自动完成属性】教程文章相关的互联网学习教程文章

javascript – ReactJS TypeError:无法读取属性’setState’【代码】

参见英文答案 > Are ‘Arrow Functions’ and ‘Functions’ equivalent / exchangeable? 1个我是ReactJS的新手,我遇到了一些问题. 我还了解了ES6语法,它说下面的代码含义相同. 1.YTSearch({key: API_KEY, term: 'nba'}, function(videos) {this.setState({ videos }); });2.YTSearch({key: API_KEY, term: 'nba'}, (videos) => {this.setState({ videos }); });但是,第一种方式抛出了这个错误...

javascript – 未捕获的TypeError:无法读取未定义的属性’push'(React-Router-Dom)【代码】

我有一个带旋转幻灯片的仪表板,每个幻灯片在Bldgs中都有一个相应的标签. Dashboard.js和Bldgs.js都是我的App.js的孩子. 当用户点击Dashboard.js中的特定幻灯片A时,Dashboard需要告诉App.js,以便App可以告诉Bldgs.js在路由到Bldgs时显示标签A. 我相信我将正确的索引值从Dashboard传递到App并向下传递给Bldgs.但是,我的App.js文件中引发了一个错误,指出: 未捕获的TypeError:无法读取未定义的属性’push’ 在我开始将handleClick()函...

javascript – 如何更新React中的嵌套状态属性【代码】

我试图通过使用这样的嵌套属性来组织我的状态:this.state = {someProperty: {flag:true} }但是像这样更新状态,this.setState({ someProperty.flag: false });不起作用.怎么能正确完成?解决方法:为了嵌套对象的setState,您可以遵循以下方法,因为我认为setState不处理嵌套更新.var someProperty = {...this.state.someProperty} someProperty.flag = true; this.setState({someProperty})我们的想法是创建一个虚拟对象对其执行操作...

javascript – 我的React组件如何理解’children’属性?【代码】

有一段时间,在撰写包装时,我正在使用:import React from "react";export default props => (<div style={{ fontWeight: "bold" }}>{props.children}</div> );但就在一秒钟之前,我遇到了这种很酷的技巧:import React from "react";export default props => <div style={{ fontWeight: "bold" }} {...props} />;它是如何工作的,我的意思是,div也是一个了解儿童属性的React组件? 此代码也有效:export default ({ children }) => (...

javascript – 如何测试React组件上定义为箭头函数(类属性)的组件方法?【代码】

我可以通过使用spies和Component.prototype来测试类方法.但是,我的许多类方法都是类属性,因为我需要使用它(对于this.setState等),并且因为构造函数中的绑定非常繁琐且看起来很丑,所以在我看来使用箭头函数要好得多.我使用类属性构建的组件在浏览器中工作,所以我知道我的babel配置是正确的.以下是我要测试的组件://Chat.jsimport React from 'react';import { connect } from 'react-redux';import { fetchThreadById, passMessage...

javascript – ReactJS无法读取undefined 的属性’bind’【代码】

参见英文答案 > Uncaught TypeError: Cannot read property ‘Checked’ of undefined – ReactJS 3个我试图通过制作一些简单的应用程序来学习reactjs.我以为我已经找到了基础知识,直到我偶然发现我使用.bind的情况.我正在尝试创建一个小列表,单击该列表将删除单击的列表项.它背后的逻辑尚未实现,因为我一直遇到同样的错误.我已经查看了其他问题,但由于某种原因我没有设法让它工作,所以如果重新...

javascript – 在react中使用元素的aria属性【代码】

我有以下渲染方法:render: function () {return (React.createElement('div', {className: 'modal', id: 'errorModal', tabIndex: '-1', role: 'dialog', ariaHidden: 'true', dataBackdrop: 'false', style: {marginTop: '30px'}}, 'text')) }这给了我错误:react.js:20541 Warning: Unknown props ariaHidden, dataBackdrop ontag. Remove these props from the element. For details, seein div (created by Constructor)in Co...

javascript – React – Uncaught TypeError:无法读取未定义的属性’func’【代码】

我收到错误:Uncaught TypeError: Cannot read property ‘func’ of undefined然而我不知道为什么,我已经用Google搜索了错误,并以相同的错误去了所有人的帖子但没有运气.谁能帮我吗? 我正在使用react-router@3.0.2 index.jsximport React from 'react'; import ReactDOM from 'react-dom'; import { Router, browserHistory } from 'react-router'; import { Helmet } from 'react-helmet';import Routes from './config/routes'...

javascript – JSX React中的动态tabIndex属性【代码】

如何以相同的方式有条件地在React组件上设置tabIndex属性,比如设置’disabled’属性? 我需要能够一起设置值和/或删除属性. 首先尝试使整个属性键和值变量:<div { tabIndex } ></div>但是编译器抱怨道. 第二个想法是:const div; if( condition ){div = <div tabIndex="1"></div> }else{div = <div></div> }但是,这是不可取的,因为我的实际组件有很多属性,我最终会有大量的重复代码. 我唯一的另一个想法是使用ref,然后使用jQuery来...

javascript – 使用ReactJS自动完成属性

我正在尝试使用autoComplete属性来获取信用卡详细信息(不以任何形式包装),但它不起作用. 任何猜测?自动填充功能是否需要https才能运行? 我使用Safari和Chrome尝试过以下操作: < input type =textplaceholder =xxxx xxxx xxxx xxxxvalue = {this.state.card} autoComplete =on/> < input type =textplaceholder =xxxx xxxx xxxx xxxxvalue = {this.state.card} autoComplete =cc-number/>解决方法:我发现我必须将所有输入包装在<...

javascript – 无法在Reactnative中读取null错误的属性“绑定”【代码】

我从react-native运行应用程序时在仿真器/设备上收到以下错误消息.** ERROR **The development server returned response error code: 500URL: http: //10.0.2.2:8081/index.delta?platform=android&dev=true&minify=falseBody: {"type": "TransformError","lineNumber": 0,"errors": [{"description": "/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-common-rn/App.js: Cannot read property 'bindings' of null"...

c# – 使用ReactiveUI的BindTo()更新XAML属性会生成警告【代码】

我正在尝试更新视图的XAML中元素的属性:this.WhenAnyValue(x => x.ViewModel.IsEnabled).BindTo(this, x => x.MyButton.IsEnabled);这可以按预期工作,但是,它会在运行时生成警告:POCOObservableForProperty: rx_bindto_test.MainWindow is a POCO type and won’t send change notifications, WhenAny will only return a single value!我可以通过将表达式更改为:来消除警告:this.WhenAnyValue(x => x.ViewModel.IsEnabled).Su...

javascript – 在调用renderComponentToStaticMarkup时使用react.js渲染onclick属性【代码】

让我们说我有一个反应组件将呈现给静态html服务器端.某些元素将具有onsubmit和onclick属性,这些属性不会被react处理,但仍应调用javascript函数.在这种特殊情况下,我想生成一个联系表单服务器端,但客户端需要加载recaptcha:var contactForm = React.createClass({render: function() {var recaptcha_id = "recaptcha_div";return(<div className="contact pure-form"><h4 className="boxedTitle">Contact Form</h4><form key="form...

javascript – 错误:无法读取未定义的React Native属性’push’【代码】

我目前正在尝试根据本教程:http://www.appcoda.com/react-native-introduction/学习React Native 复制大部分代码(文本中的小变化)时,我收到此错误:Error: Cannot read property 'push' of undefined如果我尝试推送新的导航器视图,则会发生此错误.这是条纹下来的代码(最后的完整代码,但认为这里只有一个简短版本更具可读性):<TouchableHighlight onPress={() => this._rowPressed(eve)} >_rowPressed(eve) {this.props.navigator...

javascript – 在React中渲染对象属性【代码】

我有一个像这样的对象export const otherInformation = [ {"FAQ": ['Getting started guide', 'Selling policy'],"Help & Support": ['Help guide', 'Selling policy'],"Legal": ['Terms of Use', 'Privacy Policy'] }]我的代码class Information extends Component {render() {const otherInformationLoop = otherInformation.map((value, key) => {return (<div><div className="col-md-4" key={key}><div className="dashboard-...