react-native-paper
react-native-paper copied to clipboard
fix: switch ref forwarding
Summary
The Switch component was converted from a React class component to a functional component between v3 and v4, but was not converted to use React.forwardRef(). Because of this, Switch components do not accept refs in v4.
Here is a bug for the same issue that got closed in December due to inactivity: https://github.com/callstack/react-native-paper/issues/2408
Test plan
- Create a
Switchcomponent and provide a ref as a prop - Call a native function on the ref like
.focus() - Verify the native function is successful and no React warnings/errors are thrown
Hey @arasfeld, thank you for your pull request 🤗. The documentation from this branch can be viewed here.
@arasfeld thanks for opening this PR. I tried to pass a ref to a switch in the example example/src/Examples/SwitchExample.tsx but I got focus is not a function
Does it work in this RN version?
Hello 👋, this pull request has been open for more than 2 months with no activity on it. If you think this is still necessary with the latest version, please comment and ping a maintainer to get this reviewed, otherwise it will be closed automatically in 7 days.