Skip to content

Commit fac2106

Browse files
authored
Merge pull request #782 from rvsia/redirectWhenNoMapper
Redirect on examples when no mapper
2 parents d69b0b3 + d6e0062 commit fac2106

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/react-renderer-demo/src/components/component-example.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,14 @@ const mapperTab = {
157157

158158
const ComponentExample = ({ variants, schema, activeMapper, component }) => {
159159
const activeTab = mapperTab[activeMapper];
160-
const { pathname, push } = useRouter();
160+
const { pathname, push, query, asPath } = useRouter();
161161
const classes = useStyles();
162162
useEffect(() => {
163+
if (!query?.mapper) {
164+
const [path, hash] = asPath.split('#');
165+
push(`${path}?mapper=mui${hash ? `#${hash}` : ''}`);
166+
}
167+
163168
sdk.embedProject(
164169
'code-target',
165170
{

0 commit comments

Comments
 (0)