Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

www-react: Fix crash on build ending #1

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions www/react-base/src/components/RawData/RawData.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ describe('RawData component', function() {
float: 123.4,
boolean: true,
array: [321, "string", true],
null: null,
undefined: undefined,
}

assertRenderSnapshot(obj);
Expand All @@ -61,6 +63,8 @@ describe('RawData component', function() {
float: 123.4,
boolean: true,
array: observable([321, "string", true]),
null: null,
undefined: undefined,
});

assertRenderSnapshot(obj);
Expand All @@ -73,6 +77,8 @@ describe('RawData component', function() {
{int: 123},
{float: 123.4},
{boolean: true},
{null: null},
{undefined: undefined},
],
};

Expand All @@ -86,6 +92,8 @@ describe('RawData component', function() {
{int: 123},
{float: 123.4},
{boolean: true},
{null: null},
{undefined: undefined},
],
};

Expand All @@ -99,6 +107,8 @@ describe('RawData component', function() {
observable({int: 123}),
observable({float: 123.4}),
observable({boolean: true}),
observable({null: null}),
observable({undefined: undefined}),
],
});

Expand Down
13 changes: 9 additions & 4 deletions www/react-base/src/components/RawData/RawData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,30 @@ export const RawData = ({data}: RawDataProps) => {
}

const renderDataElement = (value: any) => {
if (!isObjectRaw(value) && !isArrayOfObjectsRaw(value)) {
return <dd>{value === null ? "null" : value.toString()}&nbsp;</dd>;
if (value === null) {
return <dd>{"null"}&nbsp;</dd>;
}
if (isArrayOfObjectsRaw(value)) {
else if (value === undefined) {
return <dd>{"undefined"}&nbsp;</dd>;
}
else if (isArrayOfObjectsRaw(value)) {
return (
<dd>
<ArrowExpander isExpanded={isExpanded} setIsExpanded={setIsExpanded}/>
{isExpanded ? renderArrayElements(value as any[]) : <span>{JSON.stringify(value)}</span>}
</dd>
);
}
if (isObjectRaw(value)) {
else if (isObjectRaw(value)) {
return (
<dd>
<ArrowExpander isExpanded={isExpanded} setIsExpanded={setIsExpanded}/>
{isExpanded ? <div><RawData data={value}/></div> : <></>}
</dd>
)
}

return <dd>{value.toString()}&nbsp;</dd>;
}

const renderElements = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports[`RawData component object with array of objects 1`] = `
/>
</svg>
<span>
[{"str":"string"},{"int":123},{"float":123.4},{"boolean":true}]
[{"str":"string"},{"int":123},{"float":123.4},{"boolean":true},{"null":null},{}]
</span>
</dd>
</div>
Expand Down Expand Up @@ -139,6 +139,40 @@ exports[`RawData component object with array of objects expanded 1`] = `
</div>
</dl>
</li>
<li>
<dl
className="dl-horizontal"
>
<div
className="bb-raw-data-key-value"
>
<dt>
null
</dt>
<dd>
null

</dd>
</div>
</dl>
</li>
<li>
<dl
className="dl-horizontal"
>
<div
className="bb-raw-data-key-value"
>
<dt>
undefined
</dt>
<dd>
undefined

</dd>
</div>
</dl>
</li>
</ul>
</dd>
</div>
Expand Down Expand Up @@ -204,6 +238,28 @@ exports[`RawData component observable object 1`] = `

</dd>
</div>
<div
className="bb-raw-data-key-value"
>
<dt>
null
</dt>
<dd>
null

</dd>
</div>
<div
className="bb-raw-data-key-value"
>
<dt>
undefined
</dt>
<dd>
undefined

</dd>
</div>
</dl>
`;

Expand Down Expand Up @@ -239,7 +295,7 @@ exports[`RawData component observable object with array of objects 1`] = `
/>
</svg>
<span>
[{"str":"string"},{"int":123},{"float":123.4},{"boolean":true}]
[{"str":"string"},{"int":123},{"float":123.4},{"boolean":true},{"null":null},{}]
</span>
</dd>
</div>
Expand Down Expand Up @@ -305,5 +361,27 @@ exports[`RawData component simple object 1`] = `

</dd>
</div>
<div
className="bb-raw-data-key-value"
>
<dt>
null
</dt>
<dd>
null

</dd>
</div>
<div
className="bb-raw-data-key-value"
>
<dt>
undefined
</dt>
<dd>
undefined

</dd>
</div>
</dl>
`;
Loading