forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.js
More file actions
52 lines (48 loc) · 1.38 KB
/
Example.js
File metadata and controls
52 lines (48 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import React from "react";
import { Redirect } from "react-router-dom";
import PropTypes from "prop-types";
import SandboxExample from "./SandboxExample.js";
export default function Example({ data, match }) {
const { example: exampleParam, environment } = match.params;
const example = data.examples.find(e => e.slug === exampleParam);
const isNative = environment === "native";
return example ? (
isNative ? (
<SandboxExample
label={example.label}
path={example.path}
dependencies={{
"react-router-native": "latest",
"react-native-web": "latest",
"react-art": "latest",
"react-scripts": "2.0.0",
...(example.extraDependencies || {})
}}
code={example.code}
extraEmbedOptions={{ editorsize: 66, hidenavigation: true }}
/>
) : (
<SandboxExample
label={example.label}
path={example.path}
dependencies={{
"react-router-dom": "latest",
"react-scripts": "2.0.0",
...(example.extraDependencies || {})
}}
code={example.code}
/>
)
) : (
<Redirect to={`/${environment}/example/${data.examples[0].slug}`} />
);
}
Example.propTypes = {
data: PropTypes.object,
match: PropTypes.shape({
params: PropTypes.shape({
example: PropTypes.string,
environment: PropTypes.string
})
})
};