-
-
Notifications
You must be signed in to change notification settings - Fork 960
Route-Based Code Splitting #1692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+146
−11
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4f3b770
fix: sanitize dangerouslySetInnerHTML with DOMPurify to prevent XSS
Suvam-paul145 8e818b1
feat: introduce several new plays, common UI components, and a saniti…
Suvam-paul145 af3995b
Eslint version issues solved
Suvam-paul145 a6b70b3
Implemented React.lazy() + dynamic import() for all 114 plays, enabli…
Suvam-paul145 2f7a4a7
Merge branch 'reactplay:main' into route
Suvam-paul145 a088921
unusual files are reverted from this branch
Suvam-paul145 dad5e93
Merge branch 'route' of https://github.com/Suvam-paul145/react-play i…
Suvam-paul145 2345a62
Merge branch 'main' into route
priyankarpal 30ed193
Apply suggestions from code review
priyankarpal e3ece0f
fix: restore sanitizeHTML for XSS protection and fix Tube2tunes loadi…
Suvam-paul145 18ea2e0
retaining code structure of CSS file
Suvam-paul145 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| .play-error-container { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| justify-content: center; | ||
| padding: 3rem 1.5rem; | ||
| text-align: center; | ||
| min-height: 50vh; | ||
| } | ||
|
|
||
| .play-error-image { | ||
| width: 200px; | ||
| height: auto; | ||
| margin-bottom: 1.5rem; | ||
| opacity: 0.8; | ||
| } | ||
|
|
||
| .play-error-title { | ||
| font-size: 1.5rem; | ||
| font-weight: 600; | ||
| color: #333; | ||
| margin: 0 0 0.75rem; | ||
| } | ||
|
|
||
| .play-error-message { | ||
| font-size: 1rem; | ||
| color: #666; | ||
| max-width: 500px; | ||
| line-height: 1.5; | ||
| margin: 0 0 1.5rem; | ||
| } | ||
|
|
||
| .play-error-actions { | ||
| display: flex; | ||
| gap: 1rem; | ||
| } | ||
|
|
||
| .play-error-retry-button { | ||
| padding: 0.6rem 1.5rem; | ||
| font-size: 0.95rem; | ||
| font-weight: 600; | ||
| border: none; | ||
| border-radius: 6px; | ||
| cursor: pointer; | ||
| background: #00f2fe; | ||
| color: #fff; | ||
| transition: opacity 0.2s; | ||
| } | ||
|
|
||
| .play-error-back-button { | ||
| padding: 0.6rem 1.5rem; | ||
| font-size: 0.95rem; | ||
| font-weight: 600; | ||
| border: 2px solid #00f2fe; | ||
| border-radius: 6px; | ||
| cursor: pointer; | ||
| background: transparent; | ||
| color: #00f2fe; | ||
| transition: opacity 0.2s; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import React from 'react'; | ||
| import { ReactComponent as ImageOops } from 'images/img-oops.svg'; | ||
| import './PlayErrorBoundary.css'; | ||
|
|
||
| class PlayErrorBoundary extends React.Component { | ||
| constructor(props) { | ||
| super(props); | ||
| this.state = { hasError: false, error: null, isChunkError: false }; | ||
| } | ||
|
|
||
| static getDerivedStateFromError(error) { | ||
| // Detect chunk load failures (network errors loading lazy chunks) | ||
| const isChunkError = | ||
| error?.name === 'ChunkLoadError' || | ||
| /loading chunk/i.test(error?.message) || | ||
| /failed to fetch dynamically imported module/i.test(error?.message); | ||
|
|
||
| return { hasError: true, error, isChunkError }; | ||
| } | ||
|
|
||
| componentDidCatch(error, errorInfo) { | ||
| console.error(`Error loading play "${this.props.playName}":`, error, errorInfo); | ||
| } | ||
|
|
||
| handleRetry = () => { | ||
| this.setState({ hasError: false, error: null, isChunkError: false }); | ||
| }; | ||
|
|
||
| handleGoBack = () => { | ||
| window.location.href = '/plays'; | ||
| }; | ||
|
|
||
| render() { | ||
| if (this.state.hasError) { | ||
| return ( | ||
| <div className="play-error-boundary play-error-container"> | ||
| <ImageOops className="play-error-image" /> | ||
| <h2 className="play-error-title"> | ||
| {this.state.isChunkError ? 'Failed to load this play' : 'Something went wrong'} | ||
| </h2> | ||
| <p className="play-error-message"> | ||
| {this.state.isChunkError | ||
| ? 'There was a network error loading this play. Please check your connection and try again.' | ||
| : `An error occurred while rendering "${this.props.playName || 'this play'}".`} | ||
| </p> | ||
| <div className="play-error-actions"> | ||
| {this.state.isChunkError && ( | ||
| <button className="play-error-retry-button" onClick={this.handleRetry}> | ||
| Retry | ||
| </button> | ||
| )} | ||
| <button className="play-error-back-button" onClick={this.handleGoBack}> | ||
| Back to Plays | ||
| </button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return this.props.children; | ||
| } | ||
| } | ||
|
|
||
| export default PlayErrorBoundary; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.