Closed
Description
Check that this is really a bug
- I confirm
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.
- add null to the control type and see if it works
- modify the code in the swiper React Controller docs example
Swiper version
9.1.1
Platform/Target and Browser Versions
mac OS, chrome
Validations
- Follow our Code of Conduct
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
- Make sure this is a Swiper issue and not a framework-specific issue
Would you like to open a PR for this bug?
- I'm willing to open a PR