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

Support for Error Object? #7

Open
pansong291 opened this issue Sep 26, 2023 · 5 comments
Open

Support for Error Object? #7

pansong291 opened this issue Sep 26, 2023 · 5 comments
Assignees

Comments

@pansong291
Copy link

const data = {  err: new Error('unknow') }
@pansong291
Copy link
Author

And is there a way to directly display primitive types? Like, strings, numbers, boolean.
For example

'hello world'
new Date()
true
Symbol.iterator

@pansong291
Copy link
Author

I found that the Error object was rendered as a valid URL, but React does not allow direct rendering of Error objects, resulting in an exception being thrown.

@pansong291
Copy link
Author

Moreover, strings in the form of 'foo: bar' are rendered as hyperlinks.

@monojack monojack self-assigned this Apr 7, 2024
@monojack
Copy link
Owner

monojack commented Apr 7, 2024

Hi, @pansong291!

Can you provide a way to reproduce this case, it might be something specific, because error objects seem to render fine. Also, have you tried the demo? https://monojack.github.io/react-object-view/
You can edit the input to see how everything is displayed

{
  err: new Error('unknow'),
  string: 'hello world',
  date: new Date(),
  bool: true,
  iterator: Symbol.iterator
}

renders:
image

As for the foo:bar rendering as a hyperlink, I will push a quick fix in a few minutes

@pansong291
Copy link
Author

pansong291 commented Apr 9, 2024

Hello, @monojack !

I have already tried the online examples and pasted the JavaScript Object you provided into the Data input box, but an exception occurred as shown in the image below.
image
Details: https://react.dev/errors/31?invariant=31&args%5B%5D=Error%3A%20unknow&args%5B%5D=

Then, this project is rendered based on Object, and the provided data must be an object. Can it support direct rendering of other types? For example, I want to directly provide a string without putting it into an object first. The following image showcases the appearance of directly rendering a string and an array.
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants