File tree 9 files changed +322
-39
lines changed
9 files changed +322
-39
lines changed Original file line number Diff line number Diff line change 19
19
npm-debug.log *
20
20
yarn-debug.log *
21
21
yarn-error.log *
22
+
23
+ .vscode
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3
3
"version" : " 0.1.0" ,
4
4
"private" : true ,
5
5
"dependencies" : {
6
+ "firebase" : " ^5.5.5" ,
6
7
"react" : " ^16.5.2" ,
7
8
"react-dom" : " ^16.5.2" ,
8
9
"react-router-dom" : " ^4.3.1" ,
Original file line number Diff line number Diff line change 1
- import React , { Component } from 'react' ;
1
+ import React from 'react' ;
2
2
// import logo from './logo.svg';
3
- import './App.css' ;
3
+ // import './App.css';
4
+ import Router from './router' ;
4
5
5
- class App extends Component {
6
- constructor ( ) {
7
- super ( )
8
- this . state = {
9
- count : 0 ,
10
- }
11
- }
12
-
13
- addOne = ( ) => {
14
- console . log ( "added one" , this )
15
- this . setState ( state => ( {
16
- count : state . count + 1
17
- } ) )
18
- }
19
- what = ( ) => {
20
- console . log ( this )
21
- return this
22
- }
6
+ class App extends React . Component {
23
7
render ( ) {
24
8
return (
25
- < div className = "App" >
26
- < button onClick = { this . addOne } > click me </ button >
27
- < p > you clicked me { this . state . count } times.</ p >
28
- < div className = "this" onClick = { this . what } > < button > what is this fuck</ button > </ div >
29
- </ div >
9
+ < Router />
30
10
) ;
31
11
}
32
12
}
Original file line number Diff line number Diff line change
1
+ import firebase from 'firebase/app'
2
+ import 'firebase/database'
3
+
4
+ function createAPI ( { config, version} ) {
5
+ firebase . initializeApp ( config )
6
+ return firebase . database ( ) . ref ( version )
7
+ }
8
+
9
+ const api = createAPI ( {
10
+ version : '/v0' ,
11
+ config : {
12
+ databaseURL : 'https://hacker-news.firebaseio.com'
13
+ }
14
+ } )
Original file line number Diff line number Diff line change
1
+ import React , {
2
+ Component
3
+ } from 'react'
4
+
5
+ class Home extends Component {
6
+ constructor ( ) {
7
+ super ( )
8
+ this . state = {
9
+
10
+ }
11
+ }
12
+ render ( ) {
13
+ return (
14
+ < div className = "Home" >
15
+ < p > this is Home 哦, 是主页哦! </ p >
16
+ </ div >
17
+ )
18
+ }
19
+ }
20
+
21
+ export default Home
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { HashRouter as Router , Route , Link } from "react-router-dom" ;
3
+
4
+ import Home from '../components/Home'
5
+
6
+ export default class HNRouter extends React . Component {
7
+ render ( ) {
8
+ return (
9
+ < Router >
10
+ < div >
11
+ < div className = "nav" >
12
+ < ul >
13
+ < Link to = "/" > Home</ Link >
14
+ < Link to = "/page" > Page</ Link >
15
+ < Link to = "/about" > About</ Link >
16
+ </ ul >
17
+ </ div >
18
+
19
+ < Route exact path = "/" component = { Home } />
20
+ </ div >
21
+ </ Router >
22
+ )
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments