json cell data view

This commit is contained in:
Jan Prochazka
2020-11-05 14:33:51 +01:00
parent 7b64e33e92
commit 399d194771
5 changed files with 188 additions and 10 deletions

View File

@@ -0,0 +1,33 @@
import React from 'react';
import styled from 'styled-components';
import ReactJson from 'react-json-view';
import ErrorInfo from '../widgets/ErrorInfo';
const OuterWrapper = styled.div`
flex: 1;
position: relative;
`;
const InnerWrapper = styled.div`
overflow: scroll;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
`;
export default function JsonCellView({ value }) {
try {
const json = JSON.parse(value);
return (
<OuterWrapper>
<InnerWrapper>
<ReactJson src={json} />
</InnerWrapper>
</OuterWrapper>
);
} catch (err) {
return <ErrorInfo message="Error parsing JSON" />;
}
}