4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

Day 61

March 15th, 2018

Hello! At the React for Beginners course by Wes Bos I learned about persisting state with firebase, which means that the state won’t disappear after reload.
Firebase is a real-time database by Google, which updates the state.

     import Rebase from 're-base';

to mirror our state to Firebase

    const base = Rebase.createClass(firebase.database());

to do reabase binding

Lifecycle events tell us when certain things are happening.

componentDidMount() {
	const { params } = this.props.match;
	this.ref = base.syncState(`${params.storeID}/fishes`, {
		context: this,
		state: "fishes"
	});
}

componentWillUnmount() {
	base.removeBinding(this.ref);
}

Huh, React is not that easy, but practice makes perfect.

Cheers!

1 upvotes $0.00

Replies (0)

Conversation

No replies yet

Replies will appear here as people join the conversation.

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: