Comparing version 1.0.7 to 1.0.8
84
index.js
@@ -1,49 +0,41 @@ | ||
const React = require("react") | ||
const { Component } = require("react") | ||
const { render } = require( "react-dom") | ||
function _defineProperty(obj, key, value) {if (key in obj) {Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });} else {obj[key] = value;}return obj;}class PureComponent extends React.PureComponent {constructor(...args) {super(...args);_defineProperty(this, "renderCounter", | ||
0);} | ||
const Stocks = ({ items }) => ( | ||
<div className="table-responsive"> | ||
<table className="table"> | ||
<tbody> | ||
{items.map(item => ( | ||
<tr> | ||
<td>{item["gsx$a"]["$t"]}</td> | ||
<td>{item["gsx$b"]["$t"]}</td> | ||
<td>{item["gsx$c"]["$t"]}</td> | ||
<td>{item["gsx$d"]["$t"]}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
); | ||
class App extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
data: [] | ||
}; | ||
} | ||
componentDidMount() { | ||
fetch( | ||
"https://spreadsheets.google.com/feeds/list/1jX90lWgKE2SmxYCfQn4AXHk1qHjupA40BauyTx2eLhI/od6/public/values?alt=json" | ||
) | ||
.then(data => data.json()) | ||
.then(jsonData => { | ||
console.log(jsonData.feed.entry.reverse()); | ||
this.setState({ | ||
data: jsonData.feed.entry.reverse() | ||
}); | ||
}); | ||
} | ||
render() { | ||
if (this.state.data.length > 0) { | ||
return <Stocks items={this.state.data} />; | ||
} | ||
return <p>Loading....</p>; | ||
} | ||
} | ||
this.renderCounter++; | ||
return /*#__PURE__*/React.createElement("h2", null, this.props.name, " rendered: ", this.renderCounter); | ||
}} | ||
render(<App />, document.getElementById("root")); | ||
class ImpureComponent extends React.Component {constructor(...args) {super(...args);_defineProperty(this, "renderCounter", | ||
0);} | ||
render() { | ||
this.renderCounter++; | ||
return /*#__PURE__*/React.createElement("h2", null, this.props.name, " rendered: ", this.renderCounter); | ||
}} | ||
class App extends React.Component {constructor(...args) {super(...args);_defineProperty(this, "state", | ||
{ | ||
renderCounter: 1 });_defineProperty(this, "onButtonPress", | ||
() => { | ||
this.setState({ renderCounter: this.state.renderCounter + 1 }); | ||
});} | ||
render() { | ||
return /*#__PURE__*/( | ||
React.createElement("div", null, /*#__PURE__*/ | ||
React.createElement("h1", null, "Pure Component"), /*#__PURE__*/ | ||
React.createElement("h2", null, "App rendered: ", this.state.renderCounter), /*#__PURE__*/ | ||
React.createElement(ImpureComponent, { name: "Impure Child Component" }), /*#__PURE__*/ | ||
React.createElement(PureComponent, { name: "Pure Child Component" }), /*#__PURE__*/ | ||
React.createElement("button", { id: "button", onClick: this.onButtonPress }, /*#__PURE__*/React.createElement("h2", null, "Trigger Render"), " "))); | ||
}} | ||
ReactDOM.render( /*#__PURE__*/React.createElement(App, null), document.getElementById('root')); |
@@ -8,3 +8,3 @@ { | ||
"version": "1.0.7" | ||
"version": "1.0.8" | ||
} |
11547
2
279