Giter Club home page Giter Club logo

little-reactjs's Introduction

little-reactjs's People

Contributors

purplebamboo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

little-reactjs's Issues

this._instantiateReactComponent()未定义

代码中的
this._instantiateReactComponent()未定义。
全局有一个instantiateReactComponent()函数。
这两个是同一个吗?

ReactCompositeComponent.prototype.receiveComponent = function(nextElement, newState) {
       ......
    if (_shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
       ........
    } else {
       ........
        //重新new一个对应的component,
        this._renderedComponent = this._instantiateReactComponent(nextRenderedElement);
       ........
    }
}

请问谁能给个UPATE_TYPES为MOVE_EXISTING的例子?

我尝试了很多,比如设 state 中 current 为 1 时,显示的是 HelloMessage2 在前,
用点击事件触发 setState 来控制 current,current 为 2 时,显示的是 HelloMessage2 在后
然而只能得到两个 "REMOVE_NODE" 和两个 "INSERT_MARKUP" 类型的 updates
但是按理说,HelloMessage2 应该被移动才对,TYPE 为 MOVE_EXISTING
简单来说我就是找不到 MOVE_EXISTING 的例子。。

`var HelloMessage2 = React.createClass({
render: function() {
return React.createElement("div", null, "112122");
}
})

var HelloMessage = React.createClass({
getInitialState: function() {
return {
type: 'say:',
current: 1,
lists: ["1", "2", "3"]
};
},
changeType: function() {
if (this.state.current === 1) {
this.setState({
type: 'shout:',
current: 2,
lists: ["2", "3", "1"],
})
this.props.name = '我已经被异步更新了,由于我使用了lastindex,所以大部分节点不需要被删除'
} else {
this.setState({
type: 'say:',
current: 1,
lists: [1, 2, 3],
})
this.props.name = "";
}
},
render: function() {
var createItem = function(itemText) {
return React.createElement("div", null, itemText);
};
var element = this.state.current === 1 ? [React.createElement(HelloMessage2), this.state.type] : [React.createElement("div", null, this.state.type), React.createElement(HelloMessage2)];
// var change_elements = this.state.current === 1 ? [React.createElement("div", null, "Hello "), React.createElement("div", null, this.props.name)] : [React.createElement("div", null, this.props.name), React.createElement("div", null, "Hello ")]
// var elements = [].concat(element, this.state.lists.map(createItem));
// var elements = [].concat(element, React.createElement("div", null, this.state.lists))
return React.createElement("div", {
onclick: this.changeType.bind(this)
}, element);
}
});

React.render(React.createElement(HelloMessage,{
name: "John"
}), document.getElementById("container"));`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.