File tree 6 files changed +35
-4
lines changed
6 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 1
- {}
1
+ {
2
+ "projects": {
3
+ "firebones": "firebones-6bc2a"
4
+ }
5
+ }
Original file line number Diff line number Diff line change @@ -10,3 +10,6 @@ public/bundle.js.map
10
10
11
11
# NPM errors
12
12
npm-debug.log
13
+
14
+ # Firebase debug log
15
+ firebase-debug.log
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -19,8 +19,9 @@ export default class extends React.Component {
19
19
this . unsubscribe ( )
20
20
}
21
21
render ( ) {
22
+ const { user} = this . state || { }
22
23
return (
23
- < WhoAmI user = { this . state . user } />
24
+ < WhoAmI user = { user } />
24
25
)
25
26
}
26
27
}
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import Jokes from './components/Jokes'
9
9
import Login from './components/Login'
10
10
import WhoAmI from './components/WhoAmI'
11
11
import NotFound from './components/NotFound'
12
+ import Scratchpad from './components/Scratchpad'
12
13
import firebase from 'APP/fire'
13
14
14
15
firebase . auth ( ) . onAuthStateChanged ( user => user || firebase . auth ( ) . signInAnonymously ( ) )
@@ -25,8 +26,9 @@ render(
25
26
< Provider store = { store } >
26
27
< Router history = { browserHistory } >
27
28
< Route path = "/" component = { ExampleApp } >
28
- < IndexRedirect to = "/jokes " />
29
+ < IndexRedirect to = "/scratchpad " />
29
30
< Route path = "/jokes" component = { Jokes } />
31
+ < Route path = "/scratchpad" component = { Scratchpad } />
30
32
</ Route >
31
33
< Route path = '*' component = { NotFound } />
32
34
</ Router >
Original file line number Diff line number Diff line change 53
53
"express" : " ^4.14.0" ,
54
54
"finalhandler" : " ^1.0.0" ,
55
55
"firebase" : " ^3.9.0" ,
56
- "firebase-tools" : " ^3.6.1" ,
57
56
"homedir" : " ^0.6.0" ,
58
57
"passport" : " ^0.3.2" ,
59
58
"passport-facebook" : " ^2.1.1" ,
You can’t perform that action at this time.
0 commit comments