scrimba / learn-react-router-6 Goto Github PK
View Code? Open in Web Editor NEWStarter code for each scrim in Bob Ziroll's Learn React Router 6 course on Scrimba! ⚛️
Home Page: https://scrimba.com/learn/reactrouter6/
Starter code for each scrim in Bob Ziroll's Learn React Router 6 course on Scrimba! ⚛️
Home Page: https://scrimba.com/learn/reactrouter6/
The workaround for redirect not having a body property works fine on local.
export async function requireAuth() {
const isLoggedIn = false;
if (!isLoggedIn) {
const response = redirect('/login?message=You must be logged in');
response.body = true;
throw response;
}
return null;
}
However reasigning the body is problametic because it throws this error
Cannot assign to 'body' because it is a read-only property.ts(2540)
It doesn't effect the local build but it fails on Netlify build step saying that
11:49:54 AM: Netlify Build
11:49:54 AM: ────────────────────────────────────────────────────────────────
11:49:54 AM:
11:49:54 AM: ❯ Version
11:49:54 AM: @netlify/build 29.20.12
11:49:54 AM:
11:49:54 AM: ❯ Flags
11:49:54 AM: baseRelDir: true
11:49:54 AM: buildId: 64f98ea51381b90008fae837
11:49:54 AM: deployId: 64f98ea51381b90008fae839
11:49:54 AM:
11:49:54 AM: ❯ Current directory
11:49:54 AM: /opt/build/repo
11:49:54 AM:
11:49:54 AM: ❯ Config file
11:49:54 AM: No config file was defined: using default values.
11:49:54 AM:
11:49:54 AM: ❯ Context
11:49:54 AM: production
11:49:54 AM:
11:49:54 AM: Build command from Netlify app
11:49:54 AM: ────────────────────────────────────────────────────────────────
11:49:54 AM:
11:49:54 AM: $ npm run build
11:49:55 AM: > [email protected] build
11:49:55 AM: > tsc && vite build
11:49:56 AM: src/utils/index.ts(30,12): error TS2540: Cannot assign to 'body' because it is a read-only property.
11:49:57 AM:
11:49:57 AM: build.command failed
11:49:57 AM: ────────────────────────────────────────────────────────────────
11:49:57 AM:
11:49:57 AM: Error message
11:49:57 AM: Command failed with exit code 2: npm run build (https://ntl.fyi/exit-code-2)
11:49:57 AM:
11:49:57 AM: Error location
11:49:57 AM: In Build command from Netlify app:
11:49:57 AM: npm run build
11:49:57 AM:
11:49:57 AM: Resolved config
11:49:57 AM: build:
11:49:57 AM: command: npm run build
11:49:57 AM: commandOrigin: ui
11:49:57 AM: publish: /opt/build/repo/dist
11:49:57 AM: publishOrigin: ui
11:49:57 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:49:57 AM: Failing build: Failed to build site
11:49:58 AM: Finished processing build request in 15.608s
Is there a possible fix for this issue?
When i clone the repository it is showing me
``
error: invalid path '05 - Actions and Protected Routes/05 - Protected Routes - Conditionally send to :login page/AuthRequired.jsx'
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'
``
When i do 'git restore --source=HEAD :/'
`error: invalid path '05 - Actions and Protected Routes/05 - Protected Routes - Conditionally send to :login page/AuthRequired.jsx'
error: invalid path '05 - Actions and Protected Routes/05 - Protected Routes - Conditionally send to :login page/Layout.jsx'
error: invalid path '05 - Actions and Protected Routes/05 - Protected Routes - Conditionally send to :login page/README.md'
error: invalid path '05 - Actions and Protected Routes/05 - Protected Routes - Conditionally send to :login page/index.css'
error: invalid path '05 - Actions and Protected Routes/05 - Protected Routes - Conditionally send to :login page/index.html'
error: invalid path '05 - Actions and Protected Routes/05 - Protected Routes - Conditionally send to :login page/index.jsx'
error: invalid path '05 - Actions and Protected Routes/05 - Protected Routes - Conditionally send to :login page/package.json'
error: invalid path '05 - Actions and Protected Routes/05 - Protected Routes - Conditionally send to :login page/vite.config.js'
error: invalid path '05 - Actions and Protected Routes/08 - Protected Routes w: loaders/AuthRequired.jsx'
error: invalid path '05 - Actions and Protected Routes/08 - Protected Routes w: loaders/Layout.jsx'
error: invalid path '05 - Actions and Protected Routes/08 - Protected Routes w: loaders/README.md'
error: invalid path '05 - Actions and Protected Routes/08 - Protected Routes w: loaders/index.css'
error: invalid path '05 - Actions and Protected Routes/08 - Protected Routes w: loaders/index.html'
error: invalid path '05 - Actions and Protected Routes/08 - Protected Routes w: loaders/index.jsx'
error: invalid path '05 - Actions and Protected Routes/08 - Protected Routes w: loaders/package.json'
error: invalid path '05 - Actions and Protected Routes/08 - Protected Routes w: loaders/vite.config.js'
error: invalid path '05 - Actions and Protected Routes/10 - Challenge - Protected Routes w: loaders/AuthRequired.jsx'
error: invalid path '05 - Actions and Protected Routes/10 - Challenge - Protected Routes w: loaders/Layout.jsx'
error: invalid path '05 - Actions and Protected Routes/10 - Challenge - Protected Routes w: loaders/README.md'
error: invalid path '05 - Actions and Protected Routes/10 - Challenge - Protected Routes w: loaders/index.css'
error: invalid path '05 - Actions and Protected Routes/10 - Challenge - Protected Routes w: loaders/index.html'
error: invalid path '05 - Actions and Protected Routes/10 - Challenge - Protected Routes w: loaders/index.jsx'
error: invalid path '05 - Actions and Protected Routes/10 - Challenge - Protected Routes w: loaders/package.json'
error: invalid path '05 - Actions and Protected Routes/10 - Challenge - Protected Routes w: loaders/vite.config.js'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/README.md'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/api.js'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/assets/images/about-hero.png'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/assets/images/avatar-icon.png'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/assets/images/home-hero.png'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/components/Error.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/components/Footer.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/components/Header.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/components/HostLayout.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/components/Layout.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/index.css'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/index.html'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/index.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/package.json'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/About.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/Home.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/Host/Dashboard.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/Host/HostVanDetail.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/Host/HostVanInfo.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/Host/HostVanPhotos.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/Host/HostVanPricing.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/Host/HostVans.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/Host/Income.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/Host/Reviews.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/Login.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/NotFound.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/Vans/VanDetail.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/pages/Vans/Vans.jsx'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/server.js'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/utils.js'
error: invalid path '05 - Actions and Protected Routes/30 - Challenge - send user to :host route after log in/vite.config.js'`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.