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

[POS UI Extensions] Screen/Navigator props not reactive #2439

Open
timvandam opened this issue Oct 26, 2024 · 0 comments
Open

[POS UI Extensions] Screen/Navigator props not reactive #2439

timvandam opened this issue Oct 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@timvandam
Copy link

timvandam commented Oct 26, 2024

Please list the package(s) involved in the issue, and include the version you are using

@shopify/ui-extensions-react 2024.10

Describe the bug

Not all <Screen /> props are reactive. E.g. the presentation prop is currently bugging me. Long story short, I use a custom router for POS. This router pre-allocates <Screen /> components and fills in <Screen /> props as the new pages are routed to. This works well with the exception of the presentation prop. Changing this to toggle whether the screen is a sheet does not change the behavior of the screen, and leaves it behaving just like its initial configuration. Using key to force rerender the screen from scratch does not work. It is also not possible to get rid pre-allocation, as the <Navigator /> component does not rerender when its children change. Making the presentation prop reactive, or the Navigator rerender when its children change could solve this issue.

Steps to reproduce the behavior:

function Test() {
  const [sheet, setSheet] = useState(false);

  useEffect(() => setSheet(true), []);

  const { navigation } = useApi();

  return (
    <Navigator>
      <Screen name="a" title="a">
        <Text>Screen A</Text
        <Button title="Open Screen B" onPress={() => navigation.navigate('b')} />
      </Screen>

      <Screen name="b" title="b" presentation={{ sheet }}>
        <Text>Screen B</Text
      </Screen>

    </Navigator>
  );
}

Screen B will not open as a sheet

Expected behavior

Screen B should open as a sheet

Screenshots

Additional context

@timvandam timvandam added the bug Something isn't working label Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant