gatsby-wordpress-search icon indicating copy to clipboard operation
gatsby-wordpress-search copied to clipboard

Maximum update depth exceeded.

Open philip-akerfeldt opened this issue 5 years ago • 1 comments

Hi! I tried to set up your plugin but i encountered some issues. It happens when as soon as the page loads where the component is present.

This is the error i receive: Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render. in SearchComponent (at HeaderSearchbar.tsx:10) in StaticQueryDataRenderer (at gatsby-browser-entry.js:38)

And this is my current setup:

import React from 'react'
import { StaticQuery, graphql, navigate } from 'gatsby'
import Search from 'gatsby-wordpress-search'

const HeaderSearchbar = () => (
  <StaticQuery
    query={graphql`
      {
        allWordpressWpSearchResults {
          edges {
            node {
              id
              post_title
              searchData
              pathname
            }
          }
        }
      }
    `}
    render={data => {
      return (
        <Search
          data={data}
          minCharacters={4}
          contentCharacters={300}
          maxResults={10}
          placeholder="Search"
          onSelect={object => navigate(o.pathname)}
        />
      )
    }}
  />
)

export default HeaderSearchbar

Any ideas of what could be causing this issue?

philip-akerfeldt avatar Oct 30 '19 10:10 philip-akerfeldt

Same problem. Repo is probably dead. Decided to create my own instead.

D19cannon avatar Jan 13 '20 13:01 D19cannon