-
-
Notifications
You must be signed in to change notification settings - Fork 957
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
base: main
Are you sure you want to change the base?
Changes from all commits
4f3b770
8e818b1
af3995b
a6b70b3
2f7a4a7
a088921
dad5e93
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #!/usr/bin/env sh | ||
| . "$(dirname -- "$0")/_/husky.sh" | ||
|
|
||
| npx lint-staged | ||
| yarn pre-commit | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ import React, { useState } from 'react'; | |
| import { format } from 'date-fns'; | ||
| import * as allLocales from 'date-fns/locale'; | ||
| import { email2Slug } from 'common/services/string'; | ||
| import sanitizeHTML from 'common/utils/sanitizeHTML'; | ||
|
|
||
| const TestimonialCard = ({ home, quote, name, avatarUrl, category, created_at, email }) => { | ||
| const [formattedDate] = useState(() => { | ||
|
|
@@ -60,7 +59,7 @@ const TestimonialCard = ({ home, quote, name, avatarUrl, category, created_at, e | |
| > | ||
| <p | ||
| className="leading-relaxed text-gray-700" | ||
| dangerouslySetInnerHTML={{ __html: sanitizeHTML(replaceWithBr()) }} | ||
| dangerouslySetInnerHTML={{ __html: replaceWithBr() }} | ||
|
||
| /> | ||
| </blockquote> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import Badge from './Badge'; | ||
| import sanitizeHTML from 'common/utils/sanitizeHTML'; | ||
| import './badge.css'; | ||
|
|
||
| const BadgeDetails = ({ badge, onClose }) => { | ||
|
|
@@ -10,7 +9,7 @@ const BadgeDetails = ({ badge, onClose }) => { | |
| return `<a href="${url}" target="_blank" rel="noopener noreferrer" class="text-blue-500 hover:underline">${name}</a>`; | ||
| }); | ||
|
|
||
| return <span dangerouslySetInnerHTML={{ __html: sanitizeHTML(descriptionWithLinks) }} />; | ||
| return <span dangerouslySetInnerHTML={{ __html: descriptionWithLinks }} />; | ||
|
||
| }; | ||
|
|
||
| return ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| import React from 'react'; | ||
| import { ReactComponent as ImageOops } from 'images/img-oops.svg'; | ||
|
|
||
| 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" style={styles.container}> | ||
| <ImageOops style={styles.image} /> | ||
| <h2 style={styles.title}> | ||
| {this.state.isChunkError ? 'Failed to load this play' : 'Something went wrong'} | ||
| </h2> | ||
| <p style={styles.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 style={styles.actions}> | ||
| {this.state.isChunkError && ( | ||
| <button style={styles.retryButton} onClick={this.handleRetry}> | ||
| Retry | ||
| </button> | ||
| )} | ||
| <button style={styles.backButton} onClick={this.handleGoBack}> | ||
| Back to Plays | ||
| </button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return this.props.children; | ||
| } | ||
| } | ||
|
|
||
| const styles = { | ||
| container: { | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| padding: '3rem 1.5rem', | ||
| textAlign: 'center', | ||
| minHeight: '50vh' | ||
| }, | ||
| image: { | ||
| width: '200px', | ||
| height: 'auto', | ||
| marginBottom: '1.5rem', | ||
| opacity: 0.8 | ||
| }, | ||
| title: { | ||
| fontSize: '1.5rem', | ||
| fontWeight: 600, | ||
| color: '#333', | ||
| margin: '0 0 0.75rem' | ||
| }, | ||
| message: { | ||
| fontSize: '1rem', | ||
| color: '#666', | ||
| maxWidth: '500px', | ||
| lineHeight: 1.5, | ||
| margin: '0 0 1.5rem' | ||
| }, | ||
| actions: { | ||
| display: 'flex', | ||
| gap: '1rem' | ||
| }, | ||
| retryButton: { | ||
| padding: '0.6rem 1.5rem', | ||
| fontSize: '0.95rem', | ||
| fontWeight: 600, | ||
| border: 'none', | ||
| borderRadius: '6px', | ||
| cursor: 'pointer', | ||
| background: '#00f2fe', | ||
| color: '#fff', | ||
| transition: 'opacity 0.2s' | ||
| }, | ||
| backButton: { | ||
| padding: '0.6rem 1.5rem', | ||
| fontSize: '0.95rem', | ||
| fontWeight: 600, | ||
| border: '2px solid #00f2fe', | ||
| borderRadius: '6px', | ||
| cursor: 'pointer', | ||
| background: 'transparent', | ||
| color: '#00f2fe', | ||
| transition: 'opacity 0.2s' | ||
| } | ||
| }; | ||
|
|
||
| export default PlayErrorBoundary; |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| import axios from 'axios'; | ||
| import { useState, useEffect } from 'react'; | ||
| import { useParams } from 'react-router-dom'; | ||
| import sanitizeHTML from 'common/utils/sanitizeHTML'; | ||
| import Loading from '../components/Loading'; | ||
|
|
||
| const Article = () => { | ||
|
|
@@ -51,7 +50,7 @@ const Article = () => { | |
|
|
||
| <div | ||
| className="mt-10 devBlog-article" | ||
| dangerouslySetInnerHTML={{ __html: sanitizeHTML(article.body_html) }} | ||
| dangerouslySetInnerHTML={{ __html: article.body_html }} | ||
|
||
| /> | ||
| </div> | ||
| ) : ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| // vendors | ||
| import { Fragment, useState } from 'react'; | ||
| import sanitizeHTML from 'common/utils/sanitizeHTML'; | ||
|
|
||
| // css | ||
| import './FrontScreen.scss'; | ||
|
|
@@ -17,17 +16,17 @@ const EndScreen = ({ quizSummary, redirectHome }) => { | |
| <div className="question-number">Question: {currentQuestion?.qNo}</div> | ||
| <li | ||
| dangerouslySetInnerHTML={{ | ||
| __html: sanitizeHTML(`${currentQuestion?.question}`) | ||
| __html: `${currentQuestion?.question}` | ||
| }} | ||
| /> | ||
| <span | ||
| dangerouslySetInnerHTML={{ | ||
| __html: sanitizeHTML(`<br/><b>Ans</b>: ${currentQuestion?.correct_answer}<br/>`) | ||
| __html: `<br/><b>Ans</b>: ${currentQuestion?.correct_answer}<br/>` | ||
| }} | ||
| /> | ||
| <span | ||
| dangerouslySetInnerHTML={{ | ||
| __html: sanitizeHTML(`<b>Your Answer</b>: ${currentQuestion?.your_answer}`) | ||
| __html: `<b>Your Answer</b>: ${currentQuestion?.your_answer}` | ||
|
Comment on lines
+19
to
+29
|
||
| }} | ||
| /> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import { useEffect, useState, useCallback, useRef } from 'react'; | ||
| import sanitizeHTML from 'common/utils/sanitizeHTML'; | ||
|
|
||
| import './QuizScreen.scss'; | ||
|
|
||
|
|
@@ -150,15 +149,15 @@ function QuizScreen({ category, getQuizSummary }) { | |
| <div className={`timer ${timer <= 5 && 'caution'}`}>{timer}</div> | ||
| <div className="question-info">Question: {questionNumber + 1}</div> | ||
| <div className="question"> | ||
| <h1 dangerouslySetInnerHTML={{ __html: sanitizeHTML(currentQuestion?.question) }} /> | ||
| <h1 dangerouslySetInnerHTML={{ __html: currentQuestion?.question }} /> | ||
|
||
| </div> | ||
| <div className="options"> | ||
| {currentQuestion?.options?.map((option, index) => { | ||
| return ( | ||
| <div className="single-opt" key={index}> | ||
| <div | ||
| className={itemClassDisplayController(option)} | ||
| dangerouslySetInnerHTML={{ __html: sanitizeHTML(option) }} | ||
| dangerouslySetInnerHTML={{ __html: option }} | ||
|
||
| onClick={handleAnswerClick(option)} | ||
| /> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,10 @@ | ||
| import React from 'react'; | ||
| import sanitizeHTML from 'common/utils/sanitizeHTML'; | ||
|
|
||
| const Output = ({ md, text, mdPreviewBox }) => { | ||
| return ( | ||
| <div | ||
| className="md-editor output-div" | ||
| dangerouslySetInnerHTML={{ __html: sanitizeHTML(md.render(text)) }} | ||
| dangerouslySetInnerHTML={{ __html: md.render(text) }} | ||
|
||
| id={mdPreviewBox} | ||
| /> | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,7 +158,10 @@ function TextToSpeech(props) { | |
| <div className="tts-output-box"> | ||
| {convertedText ? ( | ||
| <> | ||
| <p className="tts-output-text">{convertedText}</p> | ||
| <p | ||
| className="tts-output-text" | ||
| dangerouslySetInnerHTML={{ __html: convertedText }} | ||
| /> | ||
|
Comment on lines
+161
to
+164
|
||
|
|
||
| <button className="tts-speaker-btn" onClick={handleSpeak}> | ||
| {isSpeaking ? <FaStop size={28} /> : <FaVolumeUp size={28} />} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -49,21 +49,16 @@ function Tube2tunes(props) { | |||||||||||||||
| .then((res) => { | ||||||||||||||||
| if (res.data.status === 'processing') { | ||||||||||||||||
| setProcessingMsg(true); | ||||||||||||||||
| setLoading(false); | ||||||||||||||||
| } else if (res.data.status === 'fail') { | ||||||||||||||||
| setFailedMsg(true); | ||||||||||||||||
|
Comment on lines
50
to
53
|
||||||||||||||||
| setLoading(false); | ||||||||||||||||
| } else { | ||||||||||||||||
| setUrlResult(res.data.link); | ||||||||||||||||
| setTitle(res.data.title); | ||||||||||||||||
| setLoading(false); | ||||||||||||||||
| } | ||||||||||||||||
| }) | ||||||||||||||||
| .catch((err) => { | ||||||||||||||||
| setError(true); | ||||||||||||||||
| setLoading(false); | ||||||||||||||||
| // eslint-disable-next-line no-console | ||||||||||||||||
| console.error('Error: ', err); | ||||||||||||||||
| .catch(() => { | ||||||||||||||||
| // console.log('Error: ', err); | ||||||||||||||||
|
Comment on lines
+60
to
+61
|
||||||||||||||||
| .catch(() => { | |
| // console.log('Error: ', err); | |
| .catch((err) => { | |
| setError(true); | |
| setLoading(false); | |
| // Optional: log error for debugging | |
| console.error('Error fetching YouTube audio:', err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is redundant and potentially confusing. The pre-commit script in package.json already runs lint-staged (line 100: "pre-commit": "lint-staged"). Changing this hook to run 'yarn pre-commit' just adds an extra indirection that eventually runs the same lint-staged command. The original 'npx lint-staged' is more direct and doesn't require yarn to be installed. Unless there's a specific reason for this change (such as additional pre-commit logic being added to the package.json script), consider reverting to 'npx lint-staged' for clarity and simplicity.