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.

ReferenceError: Can't find variable, both COLOR and ThemeProvider

See original GitHub issue

I already set the imports correctly…

import { COLOR, ThemeProvider } from 'react-native-material-ui';

I even tried to separate them…

import COLOR from 'react-native-material-ui';
import ThemeProvider from 'react-native-material-ui';

Here’s my code on the App.js, still barebone because this is my first time…

import React from 'react';
import { Platform, StyleSheet, Text, ViewNavigator, NativeModules } from 'react-native';
import { COLOR, ThemeProvider } from 'react-native-material-ui';

import Toolbar from './layouts/Toolbar/Toolbar';

const uitp =
{
  palette:
  {
    primaryColor: COLOR.green500,
  },
  toolbar:
  {
      container:
      {
          height: 50,
      },
  },
};

const styles = StyleSheet.create(
{
  fontFamily:
  {
    'font-family': 'Roboto, sans-serif',
  },
  container:
  {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome:
  {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions:
  {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

const instructions = Platform.select(
{
  ios: 'Press Cmd+R to reload,\n' +
    'Cmd+D or shake for dev menu',
  android: 'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

export default class App extends React.Component
{
  render()
  {
    return (
      <ThemeProvider uiTheme={uitp}>
        <View style={styles.container}>
          <Text style={styles.welcome}>
            Welcome to React Native!
          </Text>
          <Text style={styles.instructions}>
            To get started, edit App.js
          </Text>
          <Text style={styles.instructions}>
            {instructions}
          </Text>
        </View>
      </ThemeProvider>
    );
  }
}

But it seems like it can’t still find the variable. I already re-installed the all necessary modules and relink them. But still no luck.

Is there any solution for this strange behavior? Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
flumiiecommented, May 3, 2018

@ayushyamitabh ok I fixed it by re-setting all the npm and yarn environment variables, the yarn appdata wasn’t pointing to the correct folder, idk why and I just realized it. Plus I do need to import the Toolbar from react-native-material-ui too

0reactions
ayushyamitabhcommented, May 3, 2018

@xotahal Please close.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't find variable: React - Stack Overflow
Can't find variable : React render main.jsbundle:1509:6 mountComponent mountChildren. Any idea what might be the problem here?
Read more >
ERROR ReferenceError: Can't find variable: React #34351
ERROR ReferenceError: Can't find variable: React This error is located at: in App (at renderApplication.js:50) in RCTView (at View.js:32) in ...
Read more >
Setup NativeBase Provider
NativeBaseProvider is a component that makes the theme available throughout your app. It uses React's Context API. Add NativeBaseProvider to the root of ......
Read more >
Theme Configuration - Tailwind CSS
The theme section of your tailwind.config.js file is where you define your project's color palette, type scale, fonts, breakpoints, border radius values, ...
Read more >
Advanced Usage - styled-components
This example renders our above themed Button and a second one that uses a second ThemeProvider to invert the background and foreground colors....
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