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

Adds onError with just the ability to change the fall back value, cus… #75

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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. 👈

@@ -25,7 +27,13 @@ beforeEach(() => {
// (`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