gatsby

How to keep or resupply React Context in a Gatsby site

ぐ巨炮叔叔 提交于 2019-12-13 11:43:23
问题 I am using Gatsby as a static site generator. I use React Context API to store the information that a user is authenticated. In development mode when I type in any URL that redirects to the 404 error page the context data is lost. When I navigate to a valid page a previously logged in user is not logged in any more. I have never worked with React Context before so I am unsure what to do about it. Is that intended behavior? Are there ways to keep the user specific React Context? Do I have to

How to render all wordpress pages as a section in a single page gatsby site

不羁岁月 提交于 2019-12-13 09:55:46
问题 I am wanting to build a single page portfolio that is structured in sections like: intro projects CV contact I have a separate page for each of those sections created in wordpress. How can I render each wordpress page to one single page with gatsby? Here is where im creating gatsby pages from wordpress API: https://github.com/joeymorello/port-site/blob/master/gatsby-node.js 回答1: A very simple example might be adding something something like this to your pages/index.js : import React from

Is Netlify able to receive nested values on Forms feature? [react-dates with Formik]

泪湿孤枕 提交于 2019-12-13 02:48:51
问题 I successfully set react-dates with Formik under Gatsbyjs. Here you have a working demo: https://codesandbox.io/s/723l233my1 Now, my problem concerns netlify (or the way in which react-dates nest the values). So depending on the problem I have two questions: - Is Netlify able to receive nested objects on the Forms feature? - Can I tell react-dates to give me shallow values instead of nested objects? In the working demo you can see that the values (startDate and endDate) seems shallow: "values

Pass props from layout to children in Gatsby

孤人 提交于 2019-12-12 12:25:31
问题 How can I pass props from Gatsby layout to children (for example a Header component)? import React from "react"; export default ({ children }) => { return <div>{children()}</div>; }; The resources I found use the following format: { props.children({ ...props, foo: true }) } { this.props.children({...this.props, updateLayoutFunction }) } But since there is no props , but only children, I can't get this to work. I tried this, but it also didn't work: { children({ foo: true }) } In all cases, I

How to reset antd datepicker after submiting a value?

房东的猫 提交于 2019-12-11 18:43:16
问题 here i am providing my sample example working on codesandbox. How to reset a datepicker value after submitting a form? state = { setFieldValue: '' } onChange = (setFieldValue) => { this.setState({ setFieldValue: null }) } render() { const { values, handleSubmit } = this.props return ( <div align="center"> <Form onSubmit={handleSubmit}> <Field name="dateofbirth" label="dateOfBirth" component={DateInput} formitemlayout={formItemLayout} value={this.state.setFieldValue} onChange={this.onChange} /

How do i add favicon gatsby-config.js?

断了今生、忘了曾经 提交于 2019-12-11 17:05:36
问题 so i try to add favicon in my blog the code following bellow: in my gatsby-config.js module.exports = { siteMetadata: { title: 'Chatbiz Blog', }, plugins: [ 'gatsby-plugin-react-helmet', 'gatsby-plugin-catch-links', { resolve: 'gatsby-source-filesystem', options: { path: `${__dirname}/src/pages`, name: 'pages', icon: `https://blablabla/favicon.ico` }, }, 'gatsby-transformer-remark', ], } so the question is when i try to this code the favicon can't render in my blog how to solve the problem?

Gatsby load JSON data at runtime

对着背影说爱祢 提交于 2019-12-11 16:56:11
问题 I have a Gatsby site, there is a careers page that uses Google Hire JSON feed. I need to make it so that when someone in HR adds a new job posting (and the JSON updates) the careers page shows the new job. At the moment I'm using GraphQL with StaticQuery, so it is loading the data at build time, I need to get it to load at runtime but not sure how the best (and simplest) way to do this is? I'm using gatsby-source-hire-with-google plugin to connect and load in the JSON Here is how the

Invalid Hook Call. React

寵の児 提交于 2019-12-11 16:18:25
问题 I am new to React.js and I bought source code of web application. I have good experience in pure javascript. so I did all thing's and everything is working fine. except one I am getting the error shown in the ​screenshot. import React, { useReducer } from 'react'; const initialState = { isOpen: false, }; function reducer(state, action) { switch (action.type) { case 'TOGGLE': return { ...state, isOpen: !state.isOpen, }; default: return state; } } export const DrawerContext = React

Netlify deploy with results of TypeError: Cannot read property 'data' of undefined

二次信任 提交于 2019-12-11 14:11:40
问题 I have completed my project using Wordpress as a headless CMS, this work locally; however when deploying to netlify I am getting cannot "TypeError: Cannot read property 'replace' of undefined" The Error is referencing my node file, which is included below. I have tried changing my config file, updating my packages, and have reviewed everything locally. Everything works fine locally, and my live server is up and running fine as well, I migrated my server prior to attempting to deploy. Netlify

Conditionally Use Gatsby Link in React Compoment

北慕城南 提交于 2019-12-11 12:52:09
问题 I have a react component that contains within it a number of sub-components. I want to wrap those sub-components in an anchor tag. Now, sometimes that anchor tag will link to a sub-page, other times it will link to an external page. Now, I'm Gatsby and that means whether or not I use an <a> tag or a <Link> component depends on whether or not I'm linking to an internal page ( <Link> ) or an external page ( <a> ). See here for more details: https://www.gatsbyjs.org/docs/gatsby-link/ Now, I