草庐IT

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

javascript - 安装 react-addons-transition-group 时遇到问题

我在使用npm安装“react-addons-transition-group”时遇到问题。根据react网站:Theaddonshavemovedtoseparatepackagesaswell:react-addons-clone-with-props,react-addons-create-fragment,react-addons-css-transition-group,react-addons-linked-state-mixin,react-addons-pure-render-mixin,react-addons-shallow-compare,react-addons

javascript - react 运动的压倒性语法

我想使用https://github.com/chenglou/react-motion但是当我看到第一个例子时:import{Motion,spring}from'react-motion';//Inyourrender...{value=>{value.x}}我对ES6语法和JSX语法不知所措。我试着在babelREPL上翻译它但它去掉了JSX语法:"usestrict";React.createElement(Motion,{defaultStyle:{x:0},style:{x:spring(10)}},function(value){returnReact.createEle

javascript - 外部 react 组件看不到 React.Component

当我链接为npm包时,外部React组件显示UncaughtTypeError:Cannotreadproperty'Component'ofundefined。我将package.json中的一个包链接为"react-mapbox":"https://github.com/varya/react-mapbox.git"。然后我在代码中使用它import{render}from'react-dom';importMapBoxfrom"react-mapbox";render(Hello,world!,document.getElementById('example'));但没有任何效果

javascript - react 路由器不渲染组件

我们像这样使用react-router:ReactDOM.render(,document.getElementsByClassName("container")[0]);varAnyPic=React.createClass({render:function(){return(Helloworld)}});varPhotoView=React.createClass({render:function(){return(Thisisthephotoview)}});在包含react-router之后,以前只是localhost:8000的内容开始看起来像localhost:8000/#

javascript - 服务器 : how to get "window", "location"和其他 "window"属性以及通常是浏览器对象上的浏览器代码?

我想在浏览器和服务器上都使用浏览器代码。我的代码基本上是React组件。我想浏览代码,得到一个编译表app.js并在浏览器和服务器上同时使用它://inabrowser//onaservervarApp=require('../assets/js/react/app');但据我所知,browserify不知道window对象。我不能在服务器端要求浏览器代码,抛出一个错误:if(window.location.pathname=='/foo'){^ReferenceError:windowisnotdefined代码如下:...manyReactcomponentsgohere...//

javascript - react : get custom checkbox's checked attribute

我想用复选框进行一些自定义,它看起来像这样:所以我将我的自定义复选框包装到React组件中:require('../../less/ck-checkbox.less');varReact=require('react');varCkCheckbox=React.createClass({propTypes:{name:React.PropTypes.string,text:React.PropTypes.string,defaultChecked:React.PropTypes.bool,onChange:React.PropTypes.func},getDefaultProps:fu

javascript - react 路由器 - 未定义的历史

我正在尝试使用1.0.0-rc1react-router和history2.0.0-rc1在按下按钮后手动浏览网站。不幸的是,按下按钮后我得到:Cannotreadproperty'pushState'ofundefined我的路由器代码:importReactfrom'react';import{Router,Route,Link,browserHistory}from'react-router'importAppContainerfrom'./components/AppContainer.jsx';importMyTabfrom'./components/test/MyTab.j

javascript - <span> 不能作为 <select> 的 child 出现在 react 中

我创建了一个选择下拉组件,我在react-redux应用程序中以redux形式使用它。下拉菜单效果很好,对性能没有影响,但在浏览器中我收到以下警告。Warning:validateDOMNesting(...):cannotappearasachildof.我不确定为什么会收到此错误,因为我没有传递任何元素。这是我用来创建选择下拉列表的代码(选项是一个包含每个选项属性的对象数组。option.text是一个将由用户查看的字符串值。所以它可能类似于“选项1”或“选项2”。)return({options.map((option)=>{return{option.text}})})关于为什

javascript - 如何在 React.createClass 中使用箭头函数

我想在我的小项目中尽可能使用ES6(ES2015)。现在我想在React中使用箭头函数。//WhatIwantletText=React.createClass({componentDidMount:()=>{setInterval(this.updateCurrentTime,1000);}}//WhatIhaveletParagraph=React.createClass({render:()=>()});letText=React.createClass({getInitialState:function(){return{currentTime:(newDate()).toSt