| Total Complexity | 2 |
| Complexity/F | 0 |
| Lines of Code | 26 |
| Function Count | 0 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import React, { useEffect } from 'react' |
||
| 2 | import BlogsComponent from '~/modules/blogs/components/Blogs' |
||
| 3 | import Dispatcher from '~/modules/core/dispatch/Dispatcher' |
||
| 4 | import { getPostSummary } from '~/modules/blogs/state/action' |
||
| 5 | import { useState, useDispatch } from '~/modules/core/state/context' |
||
| 6 | |||
| 7 | const Blogs = () => { |
||
| 8 | const state = useState() |
||
| 9 | const dispatch = useDispatch() |
||
| 10 | |||
| 11 | useEffect(() => { |
||
| 12 | Dispatcher(dispatch).send(getPostSummary) |
||
| 13 | }, []) |
||
| 14 | |||
| 15 | const { loading, error, data } = state |
||
| 16 | return error ? ( |
||
| 17 | <div>{error.toString()}</div> |
||
| 18 | ) : loading ? ( |
||
| 19 | <div> </div> |
||
| 20 | ) : ( |
||
| 21 | <BlogsComponent posts={data} /> |
||
| 22 | ) |
||
| 23 | } |
||
| 24 | |||
| 25 | export default Blogs |
||
| 26 |