This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { render } from "react-dom"; | |
class App extends React.PureComponent { | |
state = { | |
showSecret: false | |
}; | |
toggleShowSecret = () => | |
this.setState({ showSecret: !this.state.showSecret }); | |
render() { | |
return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { render } from "react-dom"; | |
const IF = ({ children, condition, fallback }) => | |
condition ? children : fallback; | |
class App extends React.PureComponent { | |
state = { | |
showSecret: false | |
}; | |
toggleShowSecret = () => | |
this.setState({ showSecret: !this.state.showSecret }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import PropTypes from "prop-types"; | |
class ConditionalDisplay extends React.PureComponent { | |
static defaultProps = { | |
fallback: null | |
}; | |
static propTypes = { | |
children: PropTypes.oneOfType([PropTypes.element, PropTypes.string]) | |
.isRequired, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { bgWhite } = require("chalk"); | |
module.exports = class ProgressBar { | |
constructor() { | |
this.total; | |
this.current; | |
this.bar_length = process.stdout.columns - 30; | |
} | |
init(total) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ProgressBar = require("./ProgressBar"); | |
const { get } = require("https"); | |
const URL = "https://stackoverflow.com/"; | |
const Bar = new ProgressBar(); | |
const request = get(URL, response => { | |
const total = response.headers["content-length"]; | |
let current = 0; |