Line 11: Expected an assignment or function call and instead saw an expression
This is the error i get every time i run
npm start
in my React JS app i am writing. GraphCMS for CMS. Everything is working fine, except that when I try to map posts, it gives this error.
I suspect the problem might be related to JSHint, but I have no idea how to fix this.
Here is my code:
import React from 'react';
import { Link } from 'react-router-dom';
import { graphql} from 'react-apollo';
import gql from 'graphql-tag';
const LandingPage = ({data: {loading, allPosts}}) => {
if(!loading) {
return (
<div className="wrapper">
{allPosts.map(post => { // <-- line 11
<article className="content" key={post.id}>
<h2>{post.title}</h2>
<p dangerouslySetInnerHTML={{__html: post.description}}>
<Link to={`/post/${post.slug}`}>
<button className="btn">Read More</button>
</Link>
</p>
</article>
})}
</div>
);
}
return <h2>Loading Posts...</h2>
};
const allPosts = gql`
query allPosts {
allPosts {
id
title
description
slug
}
}
`;
export default graphql(allPosts)(LandingPage);