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

overflow: undefined breaks OverlayScrollbarsComponent #586

Closed
krutoo opened this issue Oct 27, 2023 · 3 comments
Closed

overflow: undefined breaks OverlayScrollbarsComponent #586

krutoo opened this issue Oct 27, 2023 · 3 comments
Labels

Comments

@krutoo
Copy link

krutoo commented Oct 27, 2023

Describe the bug
I use react version like this:

<OverlayScrollbarsComponent
  defer={false}
  options={{
    overflow: undefined,
  }}
>
  {children}
</OverlayScrollbarsComponent>

TypeScript types say that overflow is not required options so there is no type check errors

But when i render it then it fails with error:

TypeError: Cannot read properties of undefined (reading 'x')

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://stackblitz.com/edit/overlayscrollbars-react-l1mfu8?file=src%2Findex.css
  2. Click on Open in new tab
  3. Open dev console
  4. See errors "something is undefined"

Expected behavior
undefined value should be interpreted as not provided overflow option i think

@KingSora
Copy link
Owner

@krutoo thanks for the report :)

I'll take a look.. Im just curious, whats exactly the usecase here? What do you expext the overflow option to be when you specify it like this?

@krutoo
Copy link
Author

krutoo commented Oct 27, 2023

@KingSora this is consistent with the work of javascript, for example, when destructuring objects, you can assign a default value that will be applied regardless of whether the object has an undefined value or is not defined at all:

const source = { a: undefined };

const { a = 1, b = 2 } = source;

console.log(a, b) // 1 2

In my case i have component that passes a value to an internal component OverlayScrollbarsComponent:

function MyComponent ({ overflow }) {
  return <OverlayScrollbarsComponent options={{ overflow }} />
}

Is optional prop, but MyComponent breaks when is not passed or passed as undefined

@KingSora
Copy link
Owner

I've released v2.4.4 which should fix this issue.

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

No branches or pull requests

2 participants