next.js

How can I combine multiple loaders (CSS, LESS, ttf, etc) in NextJS config file?

房东的猫 提交于 2020-01-13 05:08:49
问题 I'm working on moving a React app to SSR using NextJS and per the docs, I'm using the CSS and LESS modules for Next. The problem is that it seems that only one works at a time. Some of the app still relies on Bootstrap for now, and I have not been able to get the Bootstrap (either CSS or LESS) to work with these loaders. The main problem is that files like .ttf, .svg, .gif, etc are referenced inside the Bootstrap stylesheets but the loaders aren't in the Next modules. Here's a general idea of

Next.js - import css file does not work

别说谁变了你拦得住时间么 提交于 2020-01-12 14:03:38
问题 I am creating a project with react, redux and next.js, and want to import CSS files in js. I followed instructions in next.js/#css and next-css, but find out that CSS styles do not work. My code is as follow: pages/index.js: import React from 'react' import "../style.css" class Index extends React.Component { render() { return ( <div className="example">Hello World!</div> ); } } export default Index next.config.js: const withCSS = require('@zeit/next-css') module.exports = withCSS() style.css

Why the data not displayed in nextjs?

断了今生、忘了曾经 提交于 2020-01-11 03:49:09
问题 I am making a very very simple nextjs application where I am trying to fetch the data from api. My requirement is I should display the data in layout.js file and this layout.js file is a children in index.js file. index.js : import Layout from "./layout"; import React from "react"; class Home extends React.Component { render() { return ( <div> <Layout /> <h4> Main content will be displayed here !! </h4> </div> ); } } export default Home; layout.js : import React from "react"; import fetch

How can I keep Google Cloud Functions warm?

隐身守侯 提交于 2020-01-09 10:06:35
问题 I know this misses the point of using Cloud Functions in the first place, but in my specific case, I'm using Cloud Functions because it's the only way I can bridge Next.js with Firebase Hosting. I don't need to make it cost-efficient, etc. With that said, the cold boot times for Cloud Functions are simply unbearable and not production-ready, averaging around 10 to 15 SECONDS for my boilerplate. I've certainly watched this video by Google (https://www.youtube.com/watch?v=IOXrwFqR6kY) that

Hooks error: Invalid Hook Call using NextJS or ReactJS on Windows

落花浮王杯 提交于 2020-01-05 03:48:11
问题 While attempting to use React Hooks in NextJS I continue to receive the following error: Hooks can only be called inside the body of a function component. This issue only occurs on Windows and works fine using Mac. This is a well documented issue and I have troubleshot many of the proposed solutions, including: Multiple versions of React or React DOM Modifying webpack settings in next.config.js Linking to specific node module pacakges Here is an example of use: import React, { useState,

How to configure nextjs 9 and ant design less compatibility?

时光总嘲笑我的痴心妄想 提交于 2020-01-04 06:38:28
问题 After upgrading react , react-dom and nextjs this error happens : Build error occurred /home/lenovo/.../node_modules/antd/lib/style/index.css:7 body { ^ SyntaxError: Unexpected token { at Module._compile (internal/modules/cjs/loader.js:720:22) at Object.Module._extensions..js (internal/modules/cjs/loader.js:788:10) at Module.load (internal/modules/cjs/loader.js:643:32) { type: 'SyntaxError', '$error': '$error' } events.js:180 throw er; // Unhandled 'error' event ^ Error: write EPIPE ... at

How to configure nextjs 9 and ant design less compatibility?

混江龙づ霸主 提交于 2020-01-04 06:36:02
问题 After upgrading react , react-dom and nextjs this error happens : Build error occurred /home/lenovo/.../node_modules/antd/lib/style/index.css:7 body { ^ SyntaxError: Unexpected token { at Module._compile (internal/modules/cjs/loader.js:720:22) at Object.Module._extensions..js (internal/modules/cjs/loader.js:788:10) at Module.load (internal/modules/cjs/loader.js:643:32) { type: 'SyntaxError', '$error': '$error' } events.js:180 throw er; // Unhandled 'error' event ^ Error: write EPIPE ... at

What's the different between react-router and Next.js

拈花ヽ惹草 提交于 2020-01-02 01:56:31
问题 i'm currently expolring ReactJS i saw NextJS and React Router Can anyone tell me what's the pro cons between the two. I'm not sure if it's right to compare the two, but from what i see, react-router already has SSR feature. So whats the benefit of using NextJS? Thanks! 回答1: Next.js (see also alternatives like GatsbyJS and After.js) are full featured SSR/static site frameworks, so you get a lot of features out of the box if you need to generate a SSR static site. These frameworks have solved

Next.js - route based modal

帅比萌擦擦* 提交于 2019-12-29 08:16:11
问题 When using Next.js, I want to show a modal based on a url, on top of another page. If gallery.js is the page component, I want /gallery/image/1232132 to display a modal with an image, on top of the gallery page. Is that possible? 回答1: yeah !!! you can use window.history.pushState for change url without switching in components. // Modal Button <button onClick={() => { this.setState({ modal: true }); window.history.pushState("","","/gallery/image/img_1233") }}> Open Modal </button> //Link

React Apollo Error: Invariant Violation: Could not find “client” in the context or passed in as an option

独自空忆成欢 提交于 2019-12-25 01:52:23
问题 I'm building a project using React, Apollo and Next.js. I'm trying to update react-apollo to 3.1.3 and I'm now getting the following error when viewing the site. Invariant Violation: Could not find "client" in the context or passed in as an option. Wrap the root component in an , or pass an ApolloClient instance in via options. If I downgrade the react-apollo package to 2.5.8 it works without issue so I'm thinking something has changed between 2.5 and 3.x but can't find anything in the react