I'm new to React and Gatsby. I'm trying to get data from a gatsby csv plugin in a component. I read that in components you have to use static query to get data but I can't make it works. I received "Cannot read property 'props' of undefined", so I think that I'm doing something wrong with the data constructor or maybe the syntax is wrong.
import React from 'react';
import { StaticQuery, graphql } from "gatsby"
const data = this.props.data.allLettersCsv.edges
export default () => (
<StaticQuery
query={graphql`
query Corrispondences {
allLettersCsv {
edges {
node {
word
value
}
}
}
}
`}
render={data.map((row,i) => (
<div>
<table>
<thead>
<tr>
<th>Letter</th>
<th>ASCII Value</th>
</tr>
</thead>
<tbody>
<tr key={`${row.node.value} ${i}`}>
<td>{row.node.word}</td>
<td>{row.node.value}</td>
</tr>
</tbody>
</table>
</div>
))
}
/>
)