|
4 | 4 | import React from "react" |
5 | 5 | import ReactDom from "react-dom" |
6 | 6 |
|
| 7 | +import Moment from "moment" |
| 8 | + |
7 | 9 | //import the react-json-view component (installed with npm) |
8 | 10 | import JsonViewer from "./../../src/js/index" |
9 | 11 |
|
@@ -39,7 +41,14 @@ ReactDom.render( |
39 | 41 | enableClipboard={copy => { |
40 | 42 | console.log("you copied to clipboard!", copy) |
41 | 43 | }} |
42 | | - shouldCollapse={({src, type}) => type === 'array' && src.indexOf('test') > -1} |
| 44 | + shouldCollapse={({ src, namespace, type }) => { |
| 45 | + if (type === "array" && src.indexOf("test") > -1) { |
| 46 | + return true |
| 47 | + } else if (namespace.indexOf("moment") > -1) { |
| 48 | + return true |
| 49 | + } |
| 50 | + return false |
| 51 | + }} |
43 | 52 | /> |
44 | 53 |
|
45 | 54 | <br /> |
@@ -67,6 +76,8 @@ ReactDom.render( |
67 | 76 | }} |
68 | 77 | name={false} |
69 | 78 | iconStyle="triangle" |
| 79 | + shouldCollapse={({ src, namespace, type }) => |
| 80 | + namespace.indexOf("moment") > -1} |
70 | 81 | /> |
71 | 82 |
|
72 | 83 | <br /> |
@@ -121,6 +132,8 @@ ReactDom.render( |
121 | 132 | <JsonViewer |
122 | 133 | enableClipboard={false} |
123 | 134 | src={getExampleJson1()} |
| 135 | + shouldCollapse={({ src, namespace, type }) => |
| 136 | + namespace.indexOf("moment") > -1} |
124 | 137 | theme={{ |
125 | 138 | base00: "white", |
126 | 139 | base01: "#ddd", |
@@ -183,7 +196,8 @@ function getExampleJson1() { |
183 | 196 | } |
184 | 197 | }, |
185 | 198 | string_number: "1234", |
186 | | - date: new Date() |
| 199 | + date: new Date(), |
| 200 | + moment: Moment() |
187 | 201 | } |
188 | 202 | } |
189 | 203 |
|
|
0 commit comments