Skip to content

Commit 45743f2

Browse files
authored
Playground - Improve componentDidMount to load uiSchema well (rjsf-team#1785)
1 parent 4932178 commit 45743f2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/playground/src/app.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ class CopyLink extends Component {
339339
class Playground extends Component {
340340
constructor(props) {
341341
super(props);
342+
343+
// set default theme
344+
const theme = "default";
342345
// initialize state with Simple data sample
343346
const { schema, uiSchema, formData, validate } = samples.Simple;
344347
this.state = {
@@ -347,7 +350,7 @@ class Playground extends Component {
347350
uiSchema,
348351
formData,
349352
validate,
350-
theme: "default",
353+
theme,
351354
subtheme: null,
352355
liveSettings: {
353356
validate: true,
@@ -361,6 +364,8 @@ class Playground extends Component {
361364
}
362365

363366
componentDidMount() {
367+
const { themes } = this.props;
368+
const { theme } = this.state;
364369
const hash = document.location.hash.match(/#(.*)/);
365370
if (hash && typeof hash[1] === "string" && hash[1].length > 0) {
366371
try {
@@ -369,7 +374,10 @@ class Playground extends Component {
369374
alert("Unable to load form setup data.");
370375
}
371376
} else {
372-
this.load({ theme: Object.keys(this.props.themes)[0] });
377+
// initialize theme
378+
this.onThemeSelected(theme, themes[theme]);
379+
380+
this.setState({ form: true });
373381
}
374382
}
375383

0 commit comments

Comments
 (0)