import React from 'react'
import Path from '../path'
import Point from '../point'
import Snippet from '../snippet'
import { getProps } from '../utils'
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(error) {
console.log(error)
return { hasError: true }
}
componentDidCatch(error, errorInfo) {
console.log(error, errorInfo)
}
render() {
if (this.state.hasError) {
console.log('in error boundary', props)
return Something went wrong.
}
return this.props.children
}
}
const XrayPart = props => {
// Don't bother if this is the only part on display
if (props.gist.only && props.gist.only.length === 1) return null
const i = props.gist._state?.xray?.reveal
? Object.keys(props.gist._state.xray.reveal).indexOf(props.partName)%10
: 0
const { topLeft, bottomRight } = props.part
return (
)
}
const Part = props => {
const { partName, part, app, gist, updateGist } = props
const grid = gist.paperless ? (
) : null
return (
{grid}
{
props.gist?._state?.xray?.enabled &&
props.gist?._state?.xray?.reveal?.[partName]
&&
}
{Object.keys(part.paths).map((pathName) => (
))}
{Object.keys(props.part.points).map((pointName) => (
))}
{Object.keys(props.part.snippets).map((snippetName) => (
))}
{focus}
)
}
/*
*/
export default Part