Skip to content

Commit 47d4f0e

Browse files
author
amandaesmith333
committed
update React files
1 parent 38d080d commit 47d4f0e

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

src/components/global/Playground/stackblitz.utils.ts

+20-17
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const openAngularEditor = async (code: string, options?: EditorOptions) => {
163163
}
164164

165165
const openReactEditor = async (code: string, options?: EditorOptions) => {
166-
let [index_tsx, app_tsx, variables_css, ts_config_json, package_json, package_lock_json, index_html] = await loadSourceFiles([
166+
const defaultFiles = await loadSourceFiles([
167167
'react/index.tsx',
168168
options?.includeIonContent ? 'react/app.withContent.tsx' : 'react/app.tsx',
169169
'react/variables.css',
@@ -173,27 +173,30 @@ const openReactEditor = async (code: string, options?: EditorOptions) => {
173173
'react/index.html',
174174
], options.version);
175175

176-
app_tsx = app_tsx.replace('{{ MODE }}', options?.mode);
176+
const appTsx = 'src/App.tsx';
177+
const files = {
178+
'public/index.html': defaultFiles[6],
179+
'src/index.tsx': defaultFiles[0],
180+
[appTsx]: defaultFiles[1],
181+
'src/main.tsx': code,
182+
'src/theme/variables.css': defaultFiles[2],
183+
'tsconfig.json': defaultFiles[3],
184+
'package.json': defaultFiles[4],
185+
'package-lock.json': defaultFiles[5],
186+
...options?.files,
187+
'.stackblitzrc': `{
188+
"startCommand": "yarn run start"
189+
}`
190+
};
191+
192+
files[appTsx] = files[appTsx].replace('setupIonicReact()', `setupIonicReact({ mode: '${options?.mode}' })`);
177193

178194
sdk.openProject({
179195
template: 'node',
180196
title: options?.title ?? DEFAULT_EDITOR_TITLE,
181197
description: options?.description ?? DEFAULT_EDITOR_DESCRIPTION,
182-
files: {
183-
'public/index.html': index_html,
184-
'src/index.tsx': index_tsx,
185-
'src/App.tsx': app_tsx,
186-
'src/main.tsx': code,
187-
'src/theme/variables.css': variables_css,
188-
'tsconfig.json': ts_config_json,
189-
'package.json': package_json,
190-
'package-lock.json': package_lock_json,
191-
...options?.files,
192-
'.stackblitzrc': `{
193-
"startCommand": "yarn run start"
194-
}`
195-
}
196-
})
198+
files
199+
});
197200
}
198201

199202
const openVueEditor = async (code: string, options?: EditorOptions) => {

static/code/stackblitz/v7/react/app.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ import './theme/variables.css';
2222

2323
import Example from './main';
2424

25-
setupIonicReact({
26-
mode: '{{ MODE }}',
27-
});
25+
setupIonicReact();
2826

2927
export default function App() {
3028
return (

0 commit comments

Comments
 (0)