fix(org): Async method in useEffect
This commit is contained in:
parent
8075a043a8
commit
fdcd57e177
1 changed files with 19 additions and 16 deletions
|
@ -22,17 +22,7 @@ const Difficulty = ({ score=1 }) => {
|
|||
return icons
|
||||
}
|
||||
|
||||
|
||||
const Design = ({ design }) => {
|
||||
const { t } = useTranslation(['patterns'])
|
||||
const {
|
||||
code="Anonymous",
|
||||
difficulty=3,
|
||||
} = configs[design]
|
||||
|
||||
const [examples, setExamples] = useState([])
|
||||
|
||||
useEffect(async () => {
|
||||
const loadDesign = async (design, setExamples) => {
|
||||
// Strapi filtering syntax
|
||||
const url = `${strapiHost}/showcaseposts?_locale=en&_sort=date:DESC` +
|
||||
`&_where[_or][0][design1_eq]=${design}` +
|
||||
|
@ -47,7 +37,20 @@ const Design = ({ design }) => {
|
|||
title: post.title
|
||||
}))))
|
||||
.catch(err => console.log(err))
|
||||
}, [ design ])
|
||||
}
|
||||
|
||||
const Design = ({ design }) => {
|
||||
const { t } = useTranslation(['patterns'])
|
||||
const {
|
||||
code="Anonymous",
|
||||
difficulty=3,
|
||||
} = configs[design]
|
||||
|
||||
const [examples, setExamples] = useState([])
|
||||
|
||||
useEffect(() => {
|
||||
loadDesign(design, setExamples)
|
||||
}, [ design, setExamples ])
|
||||
|
||||
return (
|
||||
<div className={`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue