Skip to content

Commit

Permalink
Merge pull request #7 from tscircuit/display-error
Browse files Browse the repository at this point in the history
Display error on the screen
  • Loading branch information
nogueirarissa authored Jul 17, 2023
2 parents 9e89a89 + 410dd1f commit b06a45f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/PCBViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,25 @@ export const PCBViewer = ({ children }) => {
onSetTransform: setTransform,
})

const [error, setError] = useState(null)

useEffect(() => {
// TODO re-use project builder
const projectBuilder = createProjectBuilder()
createRoot()
.render(children, projectBuilder as any)
.then((elements) => setElements(elements))
.then((elements) => {
setElements(elements)
setError(null)
})
.catch((e) => {
setError(e.toString())
console.log(e.toString())
})
}, [children])

if (error) return <div style={{ color: "red" }}> {error} </div>

if (elements.length === 0) return null

return (
Expand Down

0 comments on commit b06a45f

Please sign in to comment.