next.js

Strange issue with useQuery: Query arguments not being read

房东的猫 提交于 2019-12-19 17:46:03
问题 I have a component that passes a string ( userToFetch ) it as a variable parameter in a parameterized query. The component looks like this: // pages/index.jsx import React from 'react'; import { useQuery } from '@apollo/react-hooks'; import gql from 'graphql-tag'; const GET_USERS = gql` query users ($limit: Int!, $username: String!) { users (limit: $limit, where: { username: $username }) { username firstName } } `; const Home = () => { const userToFetch = 'jonsnow'; const { loading, error,

getDerivedStateFromProps is not called

半世苍凉 提交于 2019-12-13 12:55:15
问题 I use React 16.3.1 and next.js . And I put getDerivedStateFromProps inside the class extending PureComponent . Here is the code: Header.js import { PureComponent } from 'react' ... export default class Header extends PureComponent { constructor (props) { super(props) this.colorAnimationProps = { animationDuration: '0.4s', animationFillMode: 'forwards' } this.colorAnimationStyle = { toColor: { animationName: 'toColor', ...this.colorAnimationProps }, toTransparent: { animationName:

Now.sh build breaking due to: Support for the experimental syntax 'decorators-legacy' isn't currently enabled

大城市里の小女人 提交于 2019-12-13 03:55:56
问题 Expected: After adding decko (Support for decorators) as well as adding support for experimetalDecoractors in my tsconfig.js and using @babel/plugin-proposal-decorators in package.json . My now.sh build should build and deploy fine after creating a PR, also since the app is running perfectly locally. Results: The build actually breaks with the following error: Support for the experimental syntax 'decorators-legacy' isn't currently enabled PR: https://github.com/Futuratum/moonholdings.io/pull

React Nextjs won't compile when using react-apollo

℡╲_俬逩灬. 提交于 2019-12-13 03:10:40
问题 A very strange one here, so if anybody can shed light on it I will be impressed. Good When I use a <h1 /> inside a component and build the server with npm run dev everything will work as expected. I can replace the h1 with the <Query /> component from react-apollo the app reloads correctly and I receive data as I should. Bad However, if I restart the server either manually or with a /server file change. It will just hang indefinitely. return ( <Query query={query}> {({ loading, data, error,

FOUC when using @material-ui/core with NextJS/React

不打扰是莪最后的温柔 提交于 2019-12-13 01:27:27
问题 My simple NextJS page looks like this (results can be viewed at https://www.schandillia.com/): /* eslint-disable no-unused-vars */ import React, { PureComponent, Fragment } from 'react'; import Head from 'next/head'; import compose from 'recompose/compose'; import Layout from '../components/Layout'; import { withStyles } from '@material-ui/core/styles'; import Button from '@material-ui/core/Button'; const styles = { root: { textAlign: 'center', paddingTop: 200, }, p: { textTransform:

How to wait for complex redux-saga action flow to finish before rendering in next.js?

柔情痞子 提交于 2019-12-12 18:23:50
问题 I'm having issues with waiting "one action flow" to finish from start until the end. The app works as usual in client, but while doing stuff server-side it doesn't finish until the end. To clarify, I'm using both "next-redux-wrapper" and "next-redux-saga" properly, as I can achieve the delayed rendering when I use simpler flow with sagas. I think the mistake is mostly how I understand (or not) saga effects altogether. Some of the code is omitted for brevity. api.saga.js const makeRequest = ({

Azure: Container did not start within expected time (WebApp)

旧街凉风 提交于 2019-12-12 10:44:35
问题 I'm getting the following error when trying to deploy a webapp: ERROR - Container XXX_0 for site XXX did not start within expected time limit. Elapsed time = 1800.4463925 sec I'm trying to deploy a node app. Using automatic deployment with a .deployment file. The .deployment file looks as follows: # 1. KuduSync if [[ "$IN_PLACE_DEPLOYMENT" -ne "1" ]]; then "$KUDU_SYNC_CMD" -v 50 -f "$DEPLOYMENT_SOURCE" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;

How to navigate to another page without reloading the whole page in NextJs?

拥有回忆 提交于 2019-12-11 17:35:19
问题 I notice that in NextJs, whenever I click on a <Link> to go to another page, it calls the getInitialProps even if that "another" page is the same page. For instance, on /profile page, there are 2 components, one for "user information" and the other component for "list of orders" which is paginated. Both data used in "user information" and "list of orders" components are fetched from APIs in getInitialProps of the /profile page. When I click to go to the next page of the "list of orders"

Nextjs + expressjs + Azure Web App : two factor authentication with express ('fs' can't be used on client side)

落爺英雄遲暮 提交于 2019-12-11 17:27:27
问题 Stack : next.js/express.js/typescript/nodemon I have a dependency on azure devops api which seems to be using 'fs' under the hood. So I can't use this library in any of the pages (including in getInitialProps). I created a custom route (call it "get_data") in express server which provides me with the data. I call this route in getInitialProps of the page that will render the data (call it data.tsx) . The whole app is behind two factor authentication in azure web apps. when get_data call is

Can I export default from a variable?

帅比萌擦擦* 提交于 2019-12-11 16:42:31
问题 I would like to change my export { default } from 'MyFile' depending on certain conditions, so can I replace the file with a string variable? Currently I have something like this: let exportFrom if(SOME_CONDITION) { exportFrom = '../Something/Blah' } else { exportFrom = './SomethingElse' } export { default } from exportFrom This currently doesn't work as I get: Parsing error: Unexpected token Is there a way to do this? It is also important to note, that the reason I am doing this in the first