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

Failing test and future fix of issue #10912 #10932

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from

Commits on Oct 12, 2023

  1. Failing test for issue remix-run#10912

    See remix-run#10912
    
    For now I created a failing test for the new
    version of React Native's linking api.
    This test ensures that the listeners are cleaned up properly
    using the remove method of the new subscription
    based Linking.addEventListener function.
    The old api is outlined as deprecated here:
    https://github.com/facebook/react-native/blob/main/CHANGELOG-pre-070.md#deprecated-2
    I am also planning on submitting the
    bug-fix soon.
    
    With the fix I assume the new API of
    React-Native is all that would work for
    future versions of `react-router-native` if
    that's not what `react-router`
    maintainers want this then you may want
    to take a different approach than the code
    below and the bug-fix I will create soon,
    but if it is what react-router wants
    then we will just need to update two
    lines in react-router-native/index.tsx
    
    In this function:
    
    ```tsx
    export function useDeepLinking() {
      // ... code elided for brevity ...
    
      // Listen for URL changes
      React.useEffect(() => {
        // ... code elided ...
    
        Linking.addEventListener(URLEventType, handleURLChange);
    
        return () => {
          Linking.removeEventListener(URLEventType, handleURLChange);
        };
      }, [navigate]);
    }
    ```
    
    From this:
    
    ```tsx
        Linking.addEventListener(URLEventType, handleURLChange);
    
        return () => {
          Linking.removeEventListener(URLEventType, handleURLChange);
        };
    ```
    
    To this:
    
    ```tsx
        const subscription = Linking.addEventListener(URLEventType, handleURLChange);
    
        return () => {
          subscription.remove();
        };
    ```
    
    This change will pass the tests.
    johnsonjo4531 committed Oct 12, 2023
    Configuration menu
    Copy the full SHA
    44c73e0 View commit details
    Browse the repository at this point in the history
  2. Update contributors.yml

    johnsonjo4531 committed Oct 12, 2023
    Configuration menu
    Copy the full SHA
    c38344c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ab92dd9 View commit details
    Browse the repository at this point in the history