Skip to content

Commit 9eb8924

Browse files
queervioletqueerviolet
queerviolet
authored and
queerviolet
committed
The scratchpad works!
1 parent 57345d6 commit 9eb8924

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
lines changed

.firebaserc

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
{}
1+
{
2+
"projects": {
3+
"firebones": "firebones-6bc2a"
4+
}
5+
}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ public/bundle.js.map
1010

1111
# NPM errors
1212
npm-debug.log
13+
14+
# Firebase debug log
15+
firebase-debug.log

app/components/Scratchpad.jsx

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react'
2+
import firebase from 'APP/fire'
3+
4+
export default class extends React.Component {
5+
componentDidMount() {
6+
this.unsubscribe = firebase.database().ref('scratchpad').on('value', snapshot => this.setState({value: snapshot.val()}))
7+
}
8+
9+
componentWillUnmount() {
10+
this.unsubscribe()
11+
}
12+
13+
write = (event) => firebase.database().ref('scratchpad')
14+
.set(event.target.value)
15+
16+
render() {
17+
const {value} = this.state || {}
18+
return (
19+
<textarea value={value} onChange={this.write}/>
20+
)
21+
}
22+
}

app/components/WhoAmI.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ export default class extends React.Component {
1919
this.unsubscribe()
2020
}
2121
render() {
22+
const {user} = this.state || {}
2223
return (
23-
<WhoAmI user={this.state.user}/>
24+
<WhoAmI user={user}/>
2425
)
2526
}
2627
}

app/main.jsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Jokes from './components/Jokes'
99
import Login from './components/Login'
1010
import WhoAmI from './components/WhoAmI'
1111
import NotFound from './components/NotFound'
12+
import Scratchpad from './components/Scratchpad'
1213
import firebase from 'APP/fire'
1314

1415
firebase.auth().onAuthStateChanged(user => user || firebase.auth().signInAnonymously())
@@ -25,8 +26,9 @@ render(
2526
<Provider store={store}>
2627
<Router history={browserHistory}>
2728
<Route path="/" component={ExampleApp}>
28-
<IndexRedirect to="/jokes" />
29+
<IndexRedirect to="/scratchpad" />
2930
<Route path="/jokes" component={Jokes} />
31+
<Route path="/scratchpad" component={Scratchpad} />
3032
</Route>
3133
<Route path='*' component={NotFound} />
3234
</Router>

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"express": "^4.14.0",
5454
"finalhandler": "^1.0.0",
5555
"firebase": "^3.9.0",
56-
"firebase-tools": "^3.6.1",
5756
"homedir": "^0.6.0",
5857
"passport": "^0.3.2",
5958
"passport-facebook": "^2.1.1",

0 commit comments

Comments
 (0)