Guest User

Untitled

a guest
Dec 14th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { graphql, StaticQuery } from 'gatsby';
  4.  
  5. function TestimonialQuery({ children, identifier }) {
  6. return (
  7. <StaticQuery
  8. query={graphql`
  9. query {
  10. allContentfulTestimonial {
  11. edges {
  12. node {
  13. identifier
  14. image {
  15. title
  16. fluid(maxWidth: 437) {
  17. ...GatsbyContentfulFluid_withWebp
  18. }
  19. }
  20. }
  21. }
  22. }
  23. }
  24. `}
  25. render={({ allContentfulTestimonial }) =>
  26. children(
  27. allContentfulTestimonial.edges.find(
  28. ({ node }) => node.identifier === identifier,
  29. ),
  30. )
  31. }
  32. />
  33. );
  34. }
  35.  
  36. TestimonialQuery.propTypes = {
  37. children: PropTypes.func.isRequired,
  38. identifier: PropTypes.string.isRequired,
  39. };
  40.  
  41. export default React.memo(TestimonialQuery);
Add Comment
Please, Sign In to add comment