Skip to content

Instantly share code, notes, and snippets.

@nsisodiya
Created October 19, 2016 18:29
Show Gist options
  • Select an option

  • Save nsisodiya/3799c4c4e7f96cd692e843b8226be7f6 to your computer and use it in GitHub Desktop.

Select an option

Save nsisodiya/3799c4c4e7f96cd692e843b8226be7f6 to your computer and use it in GitHub Desktop.
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