mirror of
https://github.com/DerTyp7/notes-react.git
synced 2025-10-30 21:07:10 +01:00
init
This commit is contained in:
50
react_frontend/src/IdeaList.js
Normal file
50
react_frontend/src/IdeaList.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import React, {useState, useEffect} from 'react';
|
||||
import Idea from './Idea';
|
||||
import './css/IdeaList.scss';
|
||||
import { useParams} from 'react-router-dom'
|
||||
|
||||
function IdeaList() {
|
||||
|
||||
let params = useParams()
|
||||
let selectedIdeaId = params.ideaId;
|
||||
let [ideas, setIdeas] = useState([]);
|
||||
|
||||
const fetchIdeas = async () => {
|
||||
const data = await fetch(
|
||||
'http://localhost:5000/ideas/'
|
||||
);
|
||||
|
||||
const ideas = await data.json();
|
||||
setIdeas(ideas);
|
||||
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
fetchIdeas();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className='ideaList'>
|
||||
<div className='head'>
|
||||
<p>Your Ideas</p>
|
||||
|
||||
<img src="/" alt="" />
|
||||
<img src="/" alt="" />
|
||||
|
||||
<div className="newIdea">
|
||||
<p>+</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div className='ideaListContent'>
|
||||
|
||||
{ideas.map(idea => (
|
||||
<Idea ideaId={idea.id} title={idea.title} description={idea.content} timestamp="02.05.2021" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
export default IdeaList;
|
||||
Reference in New Issue
Block a user