File tree Expand file tree Collapse file tree 4 files changed +76
-13
lines changed Expand file tree Collapse file tree 4 files changed +76
-13
lines changed Original file line number Diff line number Diff line change 1000
1000
"publish" : false ,
1001
1001
"createdAt" : 1657255275073 ,
1002
1002
"id" : 143
1003
+ },
1004
+ {
1005
+ "title" : " tt" ,
1006
+ "body" : " tt" ,
1007
+ "publish" : false ,
1008
+ "createdAt" : 1657774109980 ,
1009
+ "id" : 144
1010
+ },
1011
+ {
1012
+ "title" : " af" ,
1013
+ "body" : " fg" ,
1014
+ "publish" : false ,
1015
+ "createdAt" : 1657774124639 ,
1016
+ "id" : 145
1017
+ },
1018
+ {
1019
+ "title" : " a" ,
1020
+ "body" : " a" ,
1021
+ "publish" : false ,
1022
+ "createdAt" : 1657774343111 ,
1023
+ "id" : 146
1024
+ },
1025
+ {
1026
+ "title" : " a" ,
1027
+ "body" : " a" ,
1028
+ "publish" : false ,
1029
+ "createdAt" : 1657774405686 ,
1030
+ "id" : 147
1031
+ },
1032
+ {
1033
+ "title" : " b" ,
1034
+ "body" : " b" ,
1035
+ "publish" : false ,
1036
+ "createdAt" : 1657774415721 ,
1037
+ "id" : 148
1038
+ },
1039
+ {
1040
+ "title" : " b" ,
1041
+ "body" : " b" ,
1042
+ "publish" : false ,
1043
+ "createdAt" : 1657774497818 ,
1044
+ "id" : 149
1045
+ },
1046
+ {
1047
+ "title" : " a" ,
1048
+ "body" : " a" ,
1049
+ "publish" : false ,
1050
+ "createdAt" : 1657775679723 ,
1051
+ "id" : 150
1052
+ },
1053
+ {
1054
+ "title" : " b" ,
1055
+ "body" : " b" ,
1056
+ "publish" : false ,
1057
+ "createdAt" : 1657775748192 ,
1058
+ "id" : 151
1003
1059
}
1004
1060
]
1005
1061
}
Original file line number Diff line number Diff line change @@ -5,16 +5,30 @@ import {
5
5
} from 'react-router-dom' ;
6
6
import NavBar from './components/NavBar' ;
7
7
import routes from './routes' ;
8
+ import Toast from './components/Toast' ;
9
+ import useToast from './hooks/toast' ;
8
10
9
11
function App ( ) {
12
+ const [ toasts , addToast , deleteToast ] = useToast ( ) ;
10
13
return (
11
14
< Router >
12
15
< NavBar />
13
-
16
+ < Toast
17
+ toasts = { toasts }
18
+ deleteToast = { deleteToast }
19
+ />
14
20
< div className = "container mt-3" >
15
21
< Switch >
16
22
{ routes . map ( ( route ) => {
17
- return < Route key = { route . path } exact path = { route . path } component = { route . component } /> ;
23
+ const Component = route . component ;
24
+ return < Route
25
+ key = { route . path }
26
+ exact
27
+ path = { route . path }
28
+ // component={route.component}
29
+ >
30
+ < Component addToast = { addToast } />
31
+ </ Route > ;
18
32
} ) }
19
33
</ Switch >
20
34
</ div >
Original file line number Diff line number Diff line change @@ -2,11 +2,8 @@ import { useEffect, useState } from 'react';
2
2
import axios from 'axios' ;
3
3
import { useHistory , useParams } from 'react-router' ;
4
4
import propTypes from 'prop-types' ;
5
- import Toast from '../components/Toast' ;
6
- import useToast from '../hooks/toast' ;
7
5
8
- const BlogForm = ( { editing } ) => {
9
- const [ toasts , addToast , deleteToast ] = useToast ( ) ;
6
+ const BlogForm = ( { editing, addToast } ) => {
10
7
const history = useHistory ( ) ;
11
8
const { id } = useParams ( ) ;
12
9
@@ -86,7 +83,7 @@ const BlogForm = ({ editing }) => {
86
83
type : 'success' ,
87
84
text : 'Successfully created!'
88
85
} ) ;
89
- // history.push('/admin');
86
+ history . push ( '/admin' ) ;
90
87
} )
91
88
}
92
89
}
@@ -98,10 +95,6 @@ const BlogForm = ({ editing }) => {
98
95
99
96
return (
100
97
< div >
101
- < Toast
102
- toasts = { toasts }
103
- deleteToast = { deleteToast }
104
- />
105
98
< h1 > { editing ? 'Edit' : 'Create' } a blog post</ h1 >
106
99
< div className = "mb-3" >
107
100
< label className = "form-label" > Title</ label >
Original file line number Diff line number Diff line change 1
1
import BlogForm from "../components/BlogForm" ;
2
2
3
- const CreatePage = ( ) => {
3
+ const CreatePage = ( { addToast } ) => {
4
4
return (
5
5
< div >
6
- < BlogForm />
6
+ < BlogForm addToast = { addToast } />
7
7
</ div >
8
8
) ;
9
9
} ;
You can’t perform that action at this time.
0 commit comments