Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/journal #100

Merged
merged 18 commits into from Aug 22, 2019
Prev

ahh error handing and mesg for no saved data

  • Loading branch information...
dubhcait committed Aug 22, 2019
commit a6398c7c04ace456bb08853082cd58ed706dc283
@@ -15,6 +15,7 @@ export default props => {
};
const [thoughts, setThoughts] = React.useState("");
const [loading, setLoading] = React.useState(true);
const [error, setError] = React.useState("");

React.useEffect(() => {
fetch("/api/v1/thoughts")
@@ -23,7 +24,7 @@ export default props => {
setThoughts(data.data);
setLoading(false);
})
.catch(err => console.log(err));
.catch(err => setError("Something went wrong"));
}, []);
return (
<>
@@ -36,7 +37,13 @@ export default props => {
<Loading />
</div>
)}
{thoughts !== "" ? <Thoughts thoughts={thoughts} /> : null}
{error && <p className='error'>{error}</p>}
{thoughts.length ? (
<Thoughts thoughts={thoughts} />
) : (
<p>You don't have any thing saved</p>
)}
<Button
name='Back'
className='large-skip__button'
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.