next.js

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

How to deploy Next.js with GraphQL backend on Zeit Now?

牧云@^-^@ 提交于 2019-12-11 11:47:03
问题 I have an Next.js/Express/Apollo GraphQL app running fine on localhost. I try to deploy it on Zeit Now, and the Next.js part works fine, but the GraphQL backend fails because /graphql route returns: 502: An error occurred with your deployment Code: NO_STATUS_CODE_FROM_LAMBDA My now.json looks like: { "version": 2, "builds": [ { "src": "next.config.js", "use": "@now/next" }, { "src": "server/server.js", "use": "@now/node" } ], "routes": [ { "src": "/api/(.*)", "dest": "server/server.js" }, {

Docker compose build time args from file

人盡茶涼 提交于 2019-12-11 08:43:49
问题 I'm aware of the variable substitutions available, where I could use a .env at the root of the project and that would be done, but in this case I'm adapting an existing project, where existing .env file locations are expected and I would like to prevent having to have var entries on multiple files! See documentation for more info, and all the code is available as WIP on the docker-support branch of the repo, but I'll succinctly describe the project and issue below: Project structure |- root |

How do I host static files on AWS S3 using next?

我只是一个虾纸丫 提交于 2019-12-11 06:25:36
问题 I'm coming from Django background where static files are mostly stored on S3, I'm trying to understand how it works on NodeJS since I'd like to migrate an app from Django/React to NodeJS/NextJS/ExpressJS/React. I don't get how & where to store my static files (client side js, css, images) on a production environment? I think to know how to upload to s3 and manage dynamic files since the work is done by the users through the express api, but I'm searching for something where I can batch upload

How to use several next.js plugins (typescript and stylus)

落花浮王杯 提交于 2019-12-11 02:25:19
问题 I try to build next.js project with typescript and stylus using next-compose-plugins. My next.config.js: const withPlugins = require('next-compose-plugins') const withTypescript = require('@zeit/next-typescript') const withStylus = require('@zeit/next-stylus') module.exports = withPlugins([ [withTypescript, { webpack(config, options) { config.node = { fs: 'empty', } return config }, typescriptLoaderOptions: { transpileOnly: false, } }], [withStylus, { cssModules: true, }], ]) In my button.tsx

unable to deploy next js to azure

不想你离开。 提交于 2019-12-11 00:55:19
问题 I am trying to deploy my NEXTJS app to azure. I created a webapplication with a linux OS containing Node installed. my package.json looks like this. { "name": "frontend", "version": "1.0.0", "description": "This package contains all necessary depenencies for frontned", "main": "index.js", "scripts": { "dev": "next", "build": "next build", "start": "next start -p $PORT", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "masnad", "license": "ISC", "dependencies": { "@zeit/next

next.js & material-ui - getting them to work

喜夏-厌秋 提交于 2019-12-11 00:44:56
问题 I'm giving next.js a spin and I can't get the simplest setup to work. Here's my setup: Relevant libs: "react": "^16.2.0", "react-dom": "^16.2.0", "next": "^4.2.2", "express": "^4.16.2", "next-routes": "^1.2.0", "material-ui": "^0.20.0", server.js const express = require('express') const next = require('next'); const routes = require('./routes'); const port = parseInt(process.env.PORT, 10) || 3000; const dev = process.env.NODE_ENV !== 'production'; const app = next({ dev }); const handler =

Import multiple files in folder in React / Nextjs

二次信任 提交于 2019-12-10 18:17:10
问题 I'm trying to import multiple files with a certain extension in a folder: const allEntries = require.context('../static/blog', true, '/\.md/') but I'm getting: Unhandled Rejection (TypeError): __webpack_require__(...).context is not a function I'm using Nextjs and require the files in one of the pages. Something seems off here? Edit: I don't necessarily need to do it via require I just want to be able to import/require multiple files at once without knowing the filename or how many of the

How to use MongoDB Stitch Auth in isomorphic or SSR app?

巧了我就是萌 提交于 2019-12-06 11:49:50
问题 Would like to use Stitch in a NextJS app (basically isomorphic react). Normally, you would be able to pass a JWT or session token in the headers of the initial request, and if the user already has a session you can immediately load all of their data and hydrate the app on the server. With Google Firebase Auth you can even do this by passing a token in the request and collecting the user on the server side using that token. I'm not sure how this would work with Stitch, though. Documentation

Next.js - Error: only absolute urls are supported

你离开我真会死。 提交于 2019-12-06 05:37:10
问题 I'm using express as my custom server for next.js. Everything is fine, when I click the products to the list of products Step 1 : I click the product Link Step 2 : It will show the products in the database. However if I refresh the /products page, I will get this Error Server code (Look at /products endpoint) app.prepare() .then(() => { const server = express() // This is the endpoints for products server.get('/api/products', (req, res, next) => { // Im using Mongoose to return the data from