Created
January 17, 2018 19:36
-
-
Save brunomacf/a20f3f434de3d69d089db9aa75d8e470 to your computer and use it in GitHub Desktop.
This file contains 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"; | |
import i18n from "darch/src/i18n"; | |
import Http from "darch/src/utils/http"; | |
import LoggerFactory from "darch/src/utils/logger"; | |
const Logger = new LoggerFactory("fake"); | |
/** | |
* Main component class. | |
*/ | |
class Fake extends React.Component { | |
static propTypes = { | |
url: PropTypes.string.isRequired, | |
http: PropTypes.object | |
}; | |
static defaultProps = {}; | |
constructor() { | |
} | |
componentDidMount() { | |
this.load(); | |
} | |
async load() { | |
const logger = Logger.create("load"); | |
logger.debug("enter"); | |
const { http } = this.prop; | |
try { | |
const data = await http.request("GET", this.props.url); | |
logger.info("got data", data); | |
this.setState({data}); | |
} catch(error) { | |
logger.error("got data error", error); | |
} | |
} | |
/** | |
* This function renders this component into the DOM. | |
* | |
* @returns {element} The component main element. | |
*/ | |
render() { | |
return ( | |
<div> | |
<i18n.Text | |
value="oi" | |
/> | |
</div> | |
); | |
} | |
} | |
export default Fake; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment