-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathQuestionPage.jsx
42 lines (33 loc) · 1.2 KB
/
QuestionPage.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React, { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { useParams } from 'react-router-dom';
import {
fetchQuestionById,
selectOpenedQuestion,
selectQuestionsFetching,
} from 'features/questions/questionsSlice';
import CommentsOfQuestion from 'features/comments/CommentsOfQuestion';
import { Paper } from 'components/layout/Paper';
import { QuestionPagePlaceholder } from './QuestionPagePlaceholder';
import { QuestionPageHeader } from './QuestionPageHeader';
import { QuestionPageContent } from './QuestionPageContent';
const { REACT_APP_FEATURE_COMMENTARIES } = process.env;
const QuestionPage = () => {
const dispatch = useDispatch();
const { id } = useParams();
const fetching = useSelector(selectQuestionsFetching);
const question = useSelector(selectOpenedQuestion);
useEffect(() => {
dispatch(fetchQuestionById(id));
}, [dispatch, id]);
return (
<div className="container">
<QuestionPageHeader />
<Paper>
{fetching || !question ? <QuestionPagePlaceholder /> : <QuestionPageContent />}
{REACT_APP_FEATURE_COMMENTARIES && <CommentsOfQuestion />}
</Paper>
</div>
);
};
export default QuestionPage;