@@ -34,14 +34,15 @@ export const ComponentCodeView = ({
34
34
const [ isCopied , setIsCopied ] = React . useState < boolean > ( false ) ;
35
35
36
36
let code = component . code . html ;
37
- if (
38
- selectedLanguage === "react" &&
39
- selectedReactCodeVariant in component . code
40
- ) {
41
- // Resets the regex so that it doesn't break in subsequent runs
42
- srcAttributeRegex . lastIndex = 0 ;
43
- code = component . code [ selectedReactCodeVariant ] ?? "" ;
37
+ if ( selectedLanguage === "react" ) {
38
+ const codeForSelectedVariant = component . code [ selectedReactCodeVariant ] ;
39
+ if ( codeForSelectedVariant ) {
40
+ code = codeForSelectedVariant ;
41
+ } else if ( component . code . react ) {
42
+ code = component . code . react ;
43
+ }
44
44
}
45
+ srcAttributeRegex . lastIndex = 0 ;
45
46
code = code . replaceAll (
46
47
srcAttributeRegex ,
47
48
( _match , uri ) => `src="https://react.email${ uri } "` ,
@@ -92,7 +93,7 @@ export const ComponentCodeView = ({
92
93
</ Tabs . List >
93
94
</ Tabs . Root >
94
95
< div className = "flex gap-2" >
95
- { selectedLanguage === "react" ? (
96
+ { selectedLanguage === "react" && ! component . code . react ? (
96
97
< ReactVariantSelect
97
98
onChange = { ( newValue ) => {
98
99
localStorage . setItem ( "code-variant" , newValue ) ;
0 commit comments