File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change 1
1
import './App.css' ;
2
- //import { LoginSignUp } from './Components/LoginSignUp/LoginSignUp';
2
+ // import { LoginSignUp } from './Components/LoginSignUp/LoginSignUp';
3
3
import { Navbar } from './Components/Navbar/Navbar' ;
4
4
import { Questions } from './Components/QuestionList/QuestionList' ;
5
5
6
6
function App ( ) {
7
7
return (
8
8
< div >
9
9
< Navbar />
10
- { /*<LoginSignUp/>*/ }
10
+ { /* <LoginSignUp/> */ }
11
11
< Questions />
12
12
13
13
</ div >
Original file line number Diff line number Diff line change @@ -47,28 +47,27 @@ export const Questions = () => {
47
47
}
48
48
49
49
const updateLocalDatabase = ( ) => {
50
- // Updating Database in Local Storageß
50
+ // Updating Database in Local Storage
51
51
updateLocalQuestionDatabase ( database ) ;
52
52
}
53
53
54
54
const updateStates = ( ) => {
55
55
// Update States
56
56
setQs ( Array . from ( database . database ) ) ;
57
- setQId ( Array . from ( database . database ) . length ) ;
57
+ setQId ( Array . from ( database . database ) . length == 0 ? 0 : Array . from ( database . database ) . sort ( ( a , b ) => a [ 0 ] < b [ 0 ] ) . slice ( - 1 ) [ 0 ] [ 0 ] ) ;
58
58
}
59
59
60
60
// To load data on mount
61
61
useEffect ( ( ) => {
62
- setQs ( Array . from ( database . database ) ) ;
63
- setQId ( Array . from ( database . database ) . length ) ;
62
+ updateStates ( ) ;
64
63
} , [ ] )
65
64
66
65
return (
67
66
68
67
< div className = "q-wrapper" >
69
68
< div className = "accordion" >
70
69
{ qs . map ( ( q , i ) => (
71
- < Question key = { q [ 0 ] } question = { q [ 1 ] } i = { i } deleteQuestion = { deleteQuestion } updateQuestion = { updateQuestion } />
70
+ < Question key = { q [ 0 ] } question = { q [ 1 ] } i = { q [ 0 ] } deleteQuestion = { deleteQuestion } updateQuestion = { updateQuestion } />
72
71
) ) }
73
72
</ div >
74
73
You can’t perform that action at this time.
0 commit comments