next.js

How to combine form using React Js? [Snippet Attached]

孤者浪人 提交于 2021-02-08 12:10:40
问题 I am trying to make a form in reactjs like this https://jsonresume.org/schema/ (JSON Format). index.js: import React, { useState, Fragment } from 'react'; import BasicDetails from '../components/basic_details'; import EmploymentDetails from '../components/employment_details'; const App = () => { const handleSubmit = (e) => { e.preventDefault(); console.log('get the whole form json here'); }; return ( <> <h1>Dynamic Form Fields in React</h1> <form onSubmit={handleSubmit}> Basic Details: <br />

NextJS reduce First Load of shared JS

我们两清 提交于 2021-02-08 11:33:26
问题 In a bigger project, I have a fairly high amount of used third-party libraries, including firebase, redux, etc and some more specific ones (but only used on several pages) like konvaJS, jimp, .... I just migrated recently to nextJS to speed up the website & maybe allow SSR. However, after migrating, the Lighthouse Speedtest dropped compared to the Pure React Version. The main problem seems to be the shared JS first Load bundles. After some optimizing, including lazy loading bigger Components

404 - File or directory not found in Next JS

你离开我真会死。 提交于 2021-02-08 11:19:32
问题 I am making a next js application. Deployment works fine in vercel. For deploying the same project in another server, got help from https://stackoverflow.com/a/63660079/13270726 and used the same instructions in our app. Deployed the out directory into server using ftp client. Issue -> When we enter into http://your-domain.com , it works fine. (Even page refresh also works fine in this page) -> If we move to about page using the url, http://your-domain.com/about then it also works but on page

Internal API fetch with getServerSideProps? (Next.js)

主宰稳场 提交于 2021-02-08 09:08:03
问题 I'm new to Next.js and I'm trying to understand the suggested structure and dealing with data between pages or components. For instance inside my home.js page, I fetch a internal API called /api/user.js where it sends back to me some user data from mongodb. The fetch right now happens inside the getServerSideProps() which passes various props to the page after some math. From my understanding this is the way to go for a good SEO, since props get fetched/modified server side and the page gets

Internal API fetch with getServerSideProps? (Next.js)

爷,独闯天下 提交于 2021-02-08 09:07:11
问题 I'm new to Next.js and I'm trying to understand the suggested structure and dealing with data between pages or components. For instance inside my home.js page, I fetch a internal API called /api/user.js where it sends back to me some user data from mongodb. The fetch right now happens inside the getServerSideProps() which passes various props to the page after some math. From my understanding this is the way to go for a good SEO, since props get fetched/modified server side and the page gets

Oauth2 Google Authentication flow - Next.JS / Express

匆匆过客 提交于 2021-02-08 05:41:29
问题 I am using a React/Next.Js Frontend and am trying to implement authentication with the Oauth2 strategy with Google. I am very confused by the process. Currently on the client, I have a Google sign in component that has a Client ID with in it and can retrieve an access token. <GoogleLogin clientId="myclientid" buttonText="Login" onSuccess={userLogin} onFailure={userLogin} cookiePolicy={'single_host_origin'} /> I then have a function, which on success sends a post message to my backend with an

Oauth2 Google Authentication flow - Next.JS / Express

情到浓时终转凉″ 提交于 2021-02-08 05:41:19
问题 I am using a React/Next.Js Frontend and am trying to implement authentication with the Oauth2 strategy with Google. I am very confused by the process. Currently on the client, I have a Google sign in component that has a Client ID with in it and can retrieve an access token. <GoogleLogin clientId="myclientid" buttonText="Login" onSuccess={userLogin} onFailure={userLogin} cookiePolicy={'single_host_origin'} /> I then have a function, which on success sends a post message to my backend with an

Transpiling NextJS for IE 10/11; 'Weakset undefined'

余生长醉 提交于 2021-02-07 13:26:59
问题 I have a NextJS website I'm building and it's great, except that it does not work in IE 10/11 because some code is not being transpiled correctly. I'm really bad with babel and webpack, and have never had to config them myself before. I've been trying to solve by reading online for two days now, and nothing seems to work for me. The exact error I get is weakSet is not defined , and it is coming from the common.js file. Here is my .babelrc file, located in the root of my project. // .babelrc {

In reactjs and nextjs constructor getting Reference Error: localstorage is not defined

时光总嘲笑我的痴心妄想 提交于 2021-02-07 10:38:36
问题 i make system jsonwebtoken in reactjs and use nextjs. i find problem when i run the code in browser that is localStorage is not defined. this is my code in file AuthStudentContext.js import React from 'react' import axios from 'axios' const axiosReq = axios.create() const AuthStudentContext = React.createContext() export class AuthStudentContextProvider extends React.Component { constructor() { super() this.state = { students: [], student: localStorage.getItem('student') || {}, token:

Next.js: document is not defined

只愿长相守 提交于 2021-02-06 10:12:39
问题 I am trying to create a payment form where people can pay but I keep getting this error. document is not defined I'm using Next.js. Please see my code below: import React from "react"; import {Elements, StripeProvider} from 'react-stripe-elements'; import CheckoutForm from '../../components/Payment/CheckoutForm'; import { useRouter } from 'next/router'; var stripe_load = () => { var aScript = document.createElement('script'); aScript.type = 'text/javascript'; aScript.src = " https://js.stripe