gatsby

Unable to update JSX attribute based on URL parameter in a Gatsby app running in production

烈酒焚心 提交于 2020-01-13 18:54:52
问题 In production mode, a URL parameter value can not be used to render dynamic attribute values. The same URL parameter value can be used to render a specific component. I have set up a repo with a minimum reproducible example. https://github.com/mikepuglisi/gatsby-dynamic-attribute-bug We've been able to work around this by storing the parameter values in state, but I don't see why that should be necessary (especially since it renders the correct div). Relevant Code (src/pages/index.js) const

Unable to update JSX attribute based on URL parameter in a Gatsby app running in production

瘦欲@ 提交于 2020-01-13 18:54:50
问题 In production mode, a URL parameter value can not be used to render dynamic attribute values. The same URL parameter value can be used to render a specific component. I have set up a repo with a minimum reproducible example. https://github.com/mikepuglisi/gatsby-dynamic-attribute-bug We've been able to work around this by storing the parameter values in state, but I don't see why that should be necessary (especially since it renders the correct div). Relevant Code (src/pages/index.js) const

Gatsby - Pass state property to GraphQL query variables/parameter?

◇◆丶佛笑我妖孽 提交于 2020-01-05 06:30:17
问题 I am new to gatsby and graphQL and am trying to build a website with this stack that will display a list of concerts/events. My question is: Is it possible to pass data from my app state down to my query variables. Where do I connect my state and my graphQL query ? Here is my code: class IndexPage extends Component { state = { term: '', date: null, } onTermChange(term) { this.setState({ term }); } render() { return ( <Layout> <SearchForm onTermChange={this.onTermChange.bind(this)} value={this

Gatsby - Pass state property to GraphQL query variables/parameter?

孤人 提交于 2020-01-05 06:30:15
问题 I am new to gatsby and graphQL and am trying to build a website with this stack that will display a list of concerts/events. My question is: Is it possible to pass data from my app state down to my query variables. Where do I connect my state and my graphQL query ? Here is my code: class IndexPage extends Component { state = { term: '', date: null, } onTermChange(term) { this.setState({ term }); } render() { return ( <Layout> <SearchForm onTermChange={this.onTermChange.bind(this)} value={this

Filtering by dates in Gatsby and Contentful

倾然丶 夕夏残阳落幕 提交于 2020-01-04 15:10:20
问题 How can you filter by dates in Gatsby? The docs allude to lt and gt operators, I get errors when I try to use them. 回答1: Filtering by date in Gatsby is potentially tricky. Many API's send dates in JSON as strings - in the ISO8601 format. That means that GraphQL will treat the dates as strings too. This is fine if you are happy filtering on string equality, but that's not usually how you want to filter on dates. A common use case is to filter to dates that are in the past or future. In most

React-hot-loader: react-🔥-dom patch is not detected

隐身守侯 提交于 2019-12-31 11:10:56
问题 I updated some npm packages in my Gatsby project and now I'm seeing this warning in console: React-hot-loader: react-🔥-dom patch is not detected. React 16.6+ features may not work. However, when I look into the source code, there is a comment: // Actually everything works... What does this warning actually mean? Is this something I should fix or just let it be? 回答1: Per my comment above, it's looking like react-hot-loader wants the @hot-loader/react-dom package instead of standard react-dom :

React-hot-loader: react-🔥-dom patch is not detected

半世苍凉 提交于 2019-12-31 11:10:19
问题 I updated some npm packages in my Gatsby project and now I'm seeing this warning in console: React-hot-loader: react-🔥-dom patch is not detected. React 16.6+ features may not work. However, when I look into the source code, there is a comment: // Actually everything works... What does this warning actually mean? Is this something I should fix or just let it be? 回答1: Per my comment above, it's looking like react-hot-loader wants the @hot-loader/react-dom package instead of standard react-dom :

add raw HTML with <script> inside Gatsby React page

非 Y 不嫁゛ 提交于 2019-12-28 06:30:24
问题 I am trying to add an external embed code to my Gatsby page. I currently use import React from 'react' import Link from 'gatsby-link' let test ="<script type='text/javascript'> (function(d, s) { var useSSL = 'https:' == document.location.protocol; var js, where = d.getElementsByTagName(s)[0], js = d.createElement(s); js.src = (useSSL ? 'https:' : 'http:') + '//www.peopleperhour.com/hire/1002307300/1213788.js?width=300&height=135&orientation=vertical&theme=light&rnd='+parseInt(Math.random()

How to include custom javascript file in gatsby project? [duplicate]

自古美人都是妖i 提交于 2019-12-27 04:48:45
问题 This question already has an answer here : How to include jQuery in a Gatsby.js project? (1 answer) Closed 4 months ago . I'm trying to add a custom javascript file to my Gatsby site but I'm still very new to Gatsby and not sure what the best way is to implement it and how. I have tried different methods but I keep getting an error: Uncaught ReferenceError: jQuery is not defined 回答1: First of all, Gatsby is a static site generator of React and usually we won't implement JQuery with React. If

Updating Data in Gatsby Source Plugin

一个人想着一个人 提交于 2019-12-25 17:07:13
问题 I have created a simple gatsby source plugin that pulls in api data. So far, so good -- it pulls in the data exactly as it should. However, there is one problem. The api data gets updated on a regular basis. That is to say, new articles get added to the api. I am wondering if it is possible to update the graphql data in Gatsby with the new articles without losing the data that was already fetched. If so, how? Thanks. P.S. In case it is relevant, here is the code of the plugin: const fetch =