You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Type error occurs when using controller function in React, typescript environment. Controller docs assign null as the useState value first.
However, if you end up assigning null, you will get the type error below.
Type 'null' is not assignable to type 'string | Swiper | HTMLElement | Swiper[] | undefined'.
Using a non-null undefined in the React 17 environment will cause the type error, and it works just fine.
Check that this is really a bug
Reproduction link
https://codesandbox.io/s/react-typescript-forked-8mg7tl?file=/src/App.tsx
Bug description
Thanks for the great library.
Type error occurs when using controller function in React, typescript environment.
Controller docs assign null as the useState value first.
However, if you end up assigning null, you will get the type error below.
Type 'null' is not assignable to type 'string | Swiper | HTMLElement | Swiper[] | undefined'.
Using a non-null undefined in the React 17 environment will cause the type error, and it works just fine.
Expected Behavior
Assigning null will not cause a type error.
Actual Behavior
null, an error is raised.
I think there are two solutions.
Swiper version
9.1.1
Platform/Target and Browser Versions
mac OS, chrome
Validations
Would you like to open a PR for this bug?
The text was updated successfully, but these errors were encountered: