Skip to content

Conversation

@dwjohnston
Copy link

@dwjohnston dwjohnston commented Nov 18, 2024

Adds a onError option, that allows the user to:

  1. Determine what the fallback value should be if a parsing error occurs.
  2. Allow any other logging functionality etc,.

// I really want to be able to write a test like this!
// But it's not working? JSDOM has implemented the storageEvent thought:
// https://github.com/jsdom/jsdom/pull/2076
test.skip("sanity test", async () => {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nb. 👈

// - "Warning: Cannot update a component (`Component`) while rendering a different component
// (`Component`). To locate the bad setState() call inside `Component`, follow the stack trace
// as described in https://reactjs.org/link/setstate-in-render"
vi.spyOn(console, 'error').mockImplementation((format: string, ...args: any[]) => {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do like this pattern.

What I've done in the past is maintained a list of allowed errors, and a second list of errors that should be printed to the console.

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

Successfully merging this pull request may close these issues.

2 participants