Passed
Push — master ( f602d8...7b3414 )
by Huu-Phat
02:55 queued 11s
created

modules/blogs/containers/Blogs.js   A

Complexity

Total Complexity 2
Complexity/F 0

Size

Lines of Code 26
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 23
mnd 2
bc 2
fnc 0
dl 0
loc 26
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
rs 10
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