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.

"You may need an appropriate loader to handle this file type" when using EvaIconsPack in react native web

See original GitHub issue

Issue type

I’m submitting a … (check one with “x”)

  • bug report
  • feature request

Issue description

Current behavior:

After installing @ui-kitten/eva-icons package and trying to setup it with <IconRegistry icons={EvaIconsPack} />, when I try to open my expo project in a web browser, I get the following error:

 web  Failed to compile.
/Users/williankrause/des/abastecame/node_modules/@ui-kitten/eva-icons/evaIcon.component.js 21:16
Module parse failed: Unexpected token (21:16)
You may need an appropriate loader to handle this file type.
|         // @ts-ignore - Eva maps icon color to `tintColor`
|         const { tintColor } = props, restProps = __rest(props, ["tintColor"]);
>         return (<Icon fill={tintColor} {...restProps}/>);
|     }
| }

It works nice on Android/iOS tho.

Expected behavior:

My app would open without a compilation error

Steps to reproduce:

Related code:

import React, {
    useState,
    useCallback,
    useContext,
    createContext,
    FunctionComponent,
    PropsWithChildren
} from 'react';
import { light, dark, mapping } from '@eva-design/eva';
import { EvaIconsPack } from '@ui-kitten/eva-icons';
import {
    ApplicationProvider,
    IconRegistry,
    ThemeType
} from 'react-native-ui-kitten';

type ThemeContextType = {
    theme: ThemeType;
    changeTheme: () => void;
    isDarkThemeActive: boolean;
};

const ThemeContext = createContext<ThemeContextType>(null);

const ThemeContextProvider: FunctionComponent<PropsWithChildren<{}>> = ({
    children
}) => {
    const [theme, setTheme] = useState(light);
    const [isDarkThemeActive, setDarkThemeActive] = useState(false);

    const changeTheme = useCallback(() => {
        setTheme(isDarkThemeActive ? light : dark);
        setDarkThemeActive(currentValue => !currentValue);
    }, [isDarkThemeActive, setDarkThemeActive, setTheme]);

    return (
        <ThemeContext.Provider
            value={{
                theme,
                changeTheme,
                isDarkThemeActive
            }}
        >
            <IconRegistry icons={EvaIconsPack} /> {/* if I comment this and lines 10/13, it works  */}
            <ApplicationProvider mapping={mapping} theme={theme}>
                {children}
            </ApplicationProvider>
        </ThemeContext.Provider>
    );
};

export const useTheme = (): ThemeContextType => useContext(ThemeContext);

export default ThemeContextProvider;

Other information:

OS, device, package version MacOS Mojave, Google Chrome

"@eva-design/eva": "^1.2.0",
"@ui-kitten/eva-icons": "^4.2.0",
"react-native-svg": "~9.9.2",
"react-native-ui-kitten": "^4.2.0",

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

3reactions
artyorshcommented, Dec 13, 2019

Got this fixed in 4.3.2 🎉 Upgrade

2reactions
RooQIcommented, Nov 19, 2019

@artyorsh And by the way, “Hello from Russia.” You have a great product.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native - You may need an appropriate loader to handle ...
React Native - You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file....
Read more >
You may need an appropriate loader to handle this ... - Reddit
It's a react component with name Banner.js , in which I have used trucate method. this is the code , I have used...
Read more >
Setting up a React Native project with Expo | Kripiz
Adding UI Kitten to Expo project ... At the moment, our project does not look like much. It would be good to add...
Read more >
you may need an appropriate loader to handle this file type react
I came across this error, what fixed it for me was putting .babelrc and webpack.config.js into the same folder as package.json .
Read more >
error: Module parse failed: Unexpected token. You may need ...
You may need an appropriate loader to handle this file type, ... Failed to compile in react native web app instance using EvaIconsPack...
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