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

<Banner theme={specificComponentTheme}> is not working #2899

Closed
zyc opened this issue Sep 10, 2021 · 8 comments · Fixed by #2932
Closed

<Banner theme={specificComponentTheme}> is not working #2899

zyc opened this issue Sep 10, 2021 · 8 comments · Fixed by #2932

Comments

@zyc
Copy link

zyc commented Sep 10, 2021

Current behaviour

When using "theme" prop of Banner component, the theme is not being applied to it.

Expected behaviour

By setting the theme prop should apply the theme on the component.

Code sample

import React, { useMemo } from 'react';
import { Banner, useTheme } from 'react-native-paper';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { parseErrorMessages } from '../utils/error-handler';

function ErrorBanner({ error, onDismiss = () => {} }) {
  const insets = useSafeAreaInsets();
  const theme = useTheme();

  const errorTheme = useMemo(() => {
    return {
      ...theme,
      colors: {
        ...theme.colors,

        primary: 'white',
        text: 'white',
        surface: theme?.colors?.notification,
      },
    };
  }, [theme]);

  const message = useMemo(() => {
    const result = parseErrorMessages(error);
    return result?.description;
  }, [error]);

  return (
    <Banner
      theme={errorTheme}
      contentStyle={{
        marginTop: message != null ? insets.top : 0,
      }}
      visible={message != null}
      actions={[
        {
          label: 'Fechar',
          onPress: onDismiss,
        },
      ]}
    >
      {message}
    </Banner>
  );
}

export { ErrorBanner };

What have you tried

I read the Theme section (https://callstack.github.io/react-native-paper/theming.html) to understand the expected behavior.

I've tried using useMemo and the straight way, but not worked.

I've tried to set only the colors props I need to change and have let te Paper do the merge, but not worked too.

I did the same with Snackbar component and worked fine.

Your Environment

software version
ios 14,7,1
android 11
react-native 0.63.2
react-native-paper 4.9.2
yarn v1.22.11
expo 42.0.3
@expo/vector-icons 12.0.0
@github-actions
Copy link

Hey! Thanks for opening the issue. The issue doesn't seem to contain a link to a repro (a snack.expo.io link or link to a GitHub repo under your username).

Can you provide a minimal repro which demonstrates the issue? A repro will help us debug the issue faster. Please try to keep the repro as small as possible and make sure that we can run it without additional setup.

@github-actions
Copy link

Couldn't find version numbers for the following packages in the issue:

  • react-native
  • react-native-vector-icons
  • expo

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

@github-actions
Copy link

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • react-native (found: 42.0.0, latest: 0.65.1)
  • expo (found: 42.0.0, latest: 42.0.3)
  • react-native-vector-icons (found: 12.0.0, latest: 8.1.0)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@github-actions
Copy link

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • react-native (found: 0.63.2, latest: 0.65.1)
  • expo (found: 42.0.0, latest: 42.0.3)
  • react-native-vector-icons (found: 12.0.0, latest: 8.1.0)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@github-actions
Copy link

Couldn't find version numbers for the following packages in the issue:

  • react-native-vector-icons

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • react-native (found: 0.63.2, latest: 0.65.1)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@zyc
Copy link
Author

zyc commented Sep 12, 2021

Couldn't find version numbers for the following packages in the issue:

  • react-native-vector-icons

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • react-native (found: 0.63.2, latest: 0.65.1)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

The vector-icons and react-native version are managed by Expo and I should not change those because compatibility reasons since I'm using the latest Expo version.

@immutable-pro
Copy link

Having the exact same issue.

@lukewalczak
Copy link
Member

Could you please provide the bug reproduction on the snack?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants