Created
October 19, 2016 18:29
-
-
Save nsisodiya/3799c4c4e7f96cd692e843b8226be7f6 to your computer and use it in GitHub Desktop.
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, {Component, PropTypes} from "react"; | |
| import FBConnectionObj from "../../services/FireBaseConnectionService"; | |
| class RealTimeVariable extends Component { | |
| constructor(props, context) { | |
| super(props, context); | |
| this.state = { | |
| value: null | |
| }; | |
| FBConnectionObj.ref(this.props.path).on("value", (snapshot) => { | |
| this.setState({ | |
| value: snapshot.val() | |
| }); | |
| }); | |
| } | |
| render() { | |
| return ( | |
| <div className={styles.container}> | |
| {this.props.render(this.state.value)} | |
| </div> | |
| ); | |
| } | |
| } | |
| RealTimeVariable.defaultProps = {}; | |
| RealTimeVariable.propTypes = { | |
| path: PropTypes.string, | |
| render: PropTypes.func | |
| }; | |
| export default RealTimeVariable; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment