jjzjj

react-router

全部标签

javascript - React setState 在 while 循环期间不设置状态

我想避免数据倍增,所以我想创建一个循环来为不同的site_id调用我的数据提供者。我创建了一个while循环并在此while循环中设置状态值。我意识到从我的2元素数组(我有2个站点)中只有1个被设置在状态中,而另一个没有。classDashboardextendsComponent{state={username:localStorage.getItem('username'),siteid:[{id:1,daily:"EKdaily",weekly:"EKweekly",monthly:"EKmonthly",total:"EKtotal",},{id:2,daily:"AKdail

javascript - 在 React Native 中动态添加组件时如何启用流畅的动画?

在我的ReactNative应用程序中,我有一张带有条件的卡片按下按钮时呈现并在触发相同按钮时删除的组件。这是我的代码的样子:this.setState({triggered:!this.state.triggered})}title="ClicktoExpand"/>Loremipsumdolorsitamet,consecteturadipiscingelit,seddoeiusmodtemporincididuntutlaboreetdoloremagnaaliqua.Utenimadminimveniam,quisnostrudexercitationullamcolabori

javascript - 错误 : "Could not find a declaration file for module ' react-search-input'"

我正在尝试安装react-input-search。我有错误:Couldnotfindadeclarationfileformodule'react-search-input'.'.../app/node_modules/react-search-input/lib/index.js'implicitlyhasan'any'type.Trynpminstall@types/react-search-inputifitexistsoraddanewdeclaration(.d.ts)filecontainingdeclaremodule'react-search-input';ts(70

javascript - react 动态事件

我很难将动态事件附加到我的React组件。我有以下组件:varListItem=React.createClass({render:function(){return({this.props.author}{this.props.children});}});varListBox=React.createClass({mixins:[MyMixin],render:function(){this.nodes=this.props.data.map(function(item){return{item.text};});return({this.nodes});}});如您所见,List

javascript - Meteor 的 Iron Router 不关闭模态对话框

我正在使用Meteor和IronRouter,并且我有一个模态对话框,当它被关闭时不会隐藏背景。更准确地说,我希望在单击关闭按钮后,ironrouter将重定向到另一个页面。重定向代码确实有效,但背景仍然可见。如果我删除路由线-模式将被关闭,背景也将被关闭。这是模态框的标记:×Areyousure?Thiscannotbeundone.YesNo这是切换模态对话框的按钮:Delete这是确认模式对话框的"is"按钮上的点击事件:'click#confirm-yes-button':function(){Recipes.remove(this._id);$('#confirm

javascript - AngularJS 中有没有一种方法可以在不使用 $watch 的情况下对模型更改使用react?

我正在AngularJS中实现一个简单的微调器控件,我想对用户输入和+/-按钮的更改使用react。这是我的HTML:但这将仅跟踪“用户更改”,因为ngChange根据documentaiton仅支持用户交互更新所以现在我正在查看$scope.$watch作为Frederikrecommends:$scope.$watch('MyProperty',function(){$scope.log('changedfrom$watch');});参见plunkerdemo但这似乎不太对。首先,它不是声明式的,您必须搜索MyTestProperty的代码才能找到此绑定(bind)。如果您想将$

javascript - 如何在 react.js 中检测父组件中的子渲染

我正在尝试缓存App组件的渲染标记。我知道这在某种程度上“违反了规则”,但我处于无服务器环境(chrome-extension)中。页面加载后,我想将缓存的App标记注入(inject)DOM。预期结果类似于在服务器上使用react-componentrendererd的体验。非常像这里描述的那样:http://www.tabforacause.org/blog/2015/01/29/using-reactjs-and-application-cache-fast-synced-app/.为了说明我的用例,我更新了Thinkinginreactexample:应用程序可过滤的产品表搜索

javascript - jsx React组件中的格式数字

这个问题已经存在:javascriptnumber/currencyformatting[duplicate]关闭7年前。我正在编写一个jsx文件,想要格式化表格中数字的显示。这是表格的代码:{stringVar}{numberVar}直接打印numberVar;如何使用C风格的字符串格式显示该数字(我需要设置精度值、添加逗号和$字符)?

javascript - 谷歌地图 react

我们尝试在我们的应用程序中嵌入谷歌地图,但没有成功。自动完成字段没有问题,但我们尝试以相同的方式插入map,但出了点问题。我们使用React0.12并为自动完成字段创建一个组件。varGeocomplete=React.createClass({componentDidMount:function(){varinputOptions={componentRestrictions:{country:'it'}};newgoogle.maps.places.Autocomplete(document.getElementById('searchTextField'),inputOption

javascript - react 教程 : Uncaught TypeError: Cannot read property 'data' of null

我正在关注React教程:http://facebook.github.io/react/docs/tutorial.html我只是之后http://facebook.github.io/react/docs/tutorial.html#fetching-from-the-server我在SO上经历了类似的问题,但没有找到适合我的具体案例的解决方案。vardata=[{author:"PeteHunt",text:"Thisisonecomment"},{author:"JordanWalke",text:"Thisis*another*comment"},{author:"BobLi