question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PaperProvider theme doesn't work for release build on IOS

See original GitHub issue

For debug build it show my custom theme but for release it shows purple color instead of mine.

Version:

    "react": "16.8.1",
    "react-native": "0.61.3",
    "react-native-paper": "3.1.1",

Code:

import {DefaultTheme, Provider as PaperProvider} from 'react-native-paper';

const theme = {
  ...DefaultTheme,
  roundness: 7,
  dark: true,
  mode: 'adaptive',
  colors: {
    ...DefaultTheme.colors,
    primary: Colors.mantis,
    accent: Colors.nero,
  },
};

const logger = createLogger();
const persistedReducer = persistReducer(persistConfig, reducers);
const store = createStore(persistedReducer, {}, applyMiddleware(ReduxThunk, logger));
const persistor = persistStore(store);


const App = () => (
  <StoreProvider store={store}>
    <PersistGate persistor={persistor}>
      <PaperProvider theme={theme}>
        <App />
      </PaperProvider>
    </PersistGate>
  </StoreProvider>
);

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
satya164commented, Nov 5, 2019

@kevinsoellner try resetting metro cache: react-native start --reset-cache or expo start -c if using expo

0reactions
KjellConnellycommented, Mar 28, 2020

Has this been fixed? I’m getting the same error when I build for release via Xcode:

Invariant Violation: Native module cannot be null.

This error is located at:
    in l
    in c
    in RCTView
    in Portal.Host
    in n
    in RCTView
    in n
    in RCTView
    in RCTView
    in h

I just updated to the latest npm version and tried pod install again. Still getting the same error message even after resetting cache.

EDIT

I figured out my problem. I just assumed since it was talking about Portal.Host, it was related to react-native-paper, especially since someone else had a similar problem. Turns out that I forgot to add a native module manually to my project since I switched computers (library was an ad library, so I just need to download that from their repo and add it to Xcode). Once I commented out my NativeModules code, release started working again. It’s because I added a flag to my code if (__DEV__) { return }.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native Paper Dark Theme on IOS - Stack Overflow
To employ a dark theme in your app, Paper provides a Material based DarkTheme. You can specify which theme to use within the...
Read more >
Theming · React Native Paper
We are planning to provide a better support of handling custom theme overrides in future releases. Simple built-in theme overrides. You can provide...
Read more >
[Solved]-React Native Paper Dark Theme on IOS-React Native
Coding example for the question React Native Paper Dark Theme on IOS-React Native.
Read more >
React Navigation v5 + React Native Paper = ❤️
It means I won't show you how to build all of the components necessary ... The PaperProvider provides the theme to all the...
Read more >
5 Easy Methods to Implement Dark Mode in React Native
Android 10 and iOS 13 brought native support of dark mode to the most ... in-built module Appearance that provides users' theme preferences....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found