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

Custom mapping not working #1009

Closed
harryy2510 opened this issue Apr 11, 2020 · 10 comments
Closed

Custom mapping not working #1009

harryy2510 opened this issue Apr 11, 2020 · 10 comments

Comments

@harryy2510
Copy link

🐛 Bug Report

Passing a custom mapping like this doesn't work for some reason
image
image

But passing it like this works
image
image

Custom mapping is the same for both scenarios
image

UI Kitten and Eva version

Package Version
@eva-design/eva ^2.0.0-alpha.1
@ui-kitten/components ^5.0.0-alpha.1

Environment information

  System:
    OS: macOS 10.15.3
    CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
  Binaries:
    Node: 13.9.0 - ~/.nvm/versions/node/v13.9.0/bin/node
    Yarn: 1.22.4 - ~/.yvm/shim/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v13.9.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 27, 28
      Build Tools: 27.0.3, 28.0.3, 29.0.3
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.4/11E146 - /usr/bin/xcodebuild
  npmPackages:
    react: ~16.13.1 => 16.13.1 
    react-native: https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz => 0.61.4 
@artyorsh
Copy link
Collaborator

@harryy2510 any chance @ui-kitten/metro-config is included in your package.json and has it's configuration in metro.config.js?

@artyorsh artyorsh added the 🤷‍♂️ Needs info There is no enough info to resolve the issue label Apr 13, 2020
@harryy2510
Copy link
Author

Yes I do have @ui-kitten/metro-config installed but doesn't have metro.config.js but instead webpack.config.js

image

image

@gabrielepmattia
Copy link

I had the same issue, I solved it by following this guide https://akveo.github.io/react-native-ui-kitten/docs/guides/improving-performance#improving-performance

@artyorsh
Copy link
Collaborator

@gabrielepmattia @harryy2510 Sorry for the late reply. Just tried it in a fresh project initialized with template and couldn't reproduce.

Could you please share a reproducible demo or describe the steps on how did you initialize?
What @ui-kitten/metro-config does is pre-generating styles during the metro bundler build time. And if it was successful, ApplicationProvider will ignore customMapping. Not having metro.config.js means not having anything pre-generated.

@artyorsh
Copy link
Collaborator

artyorsh commented Apr 27, 2020

Snack Demo

Closing this since there is no problem with this 🤷‍♂️
But I'm still interested what was wrongly configured on your side

@gabrielepmattia
Copy link

gabrielepmattia commented Apr 27, 2020

@artyorsh I created from scratch a new project, I copied your mapping.json and it is still not working. Here's the repository of the sample project (https://github.com/gabrielepmattia/react-native-ui-kitten-custom-mapping-issue), you can check the commits for seeing what I've done, maybe I'm doing something wrong. Steps to reproduce:

  1. Start new project with npx react-native init MyApp --template @ui-kitten/template-js
  2. Create mapping.json and import in App.tsx with import { default as appMapping } from './mapping.json';
  3. Add customMapping={appMapping} to ApplicationProvider in App.tsx
  4. Add resolveJsonModule in tsconfig.json for allowing loading of json files
  5. Run npx react-native run-android or npx react-native run-ios

I attach here the screenshots, again only pre-building the mapping makes the button turn pink. I also get type errors in the custom mapping and in the button icon (attached screenshot).

Screenshot 2020-04-27 at 12 04 06

Thank you for your time

P.S.: Moreover the Heart icon in the button is missing.

@phamquyhai
Copy link

@artyorsh But not working with Custom Component Mapping
I copied CircleButton and custom mapping for CircleButton. but not working.

@artyorsh
Copy link
Collaborator

@kakavip yep, thanks for the details. I fixed that in d120d5d. This is an upcoming change anyway, but if you need to use it currently, this may achieved by modifying props like the migration guide says. Sorry for such type of issue.

@gabrielepmattia thanks for the details 👍The commit above also gives some notes on this. The problem is you use metro configuration which creates a styles during the build time. customMapping property is not required in this case as it is completely ignored. What you can do is modifying your metro.config.js with.

const evaConfig = {
  evaPackage: '@eva-design/eva',
  customMappingPath: './path-to/custom-mapping.json', 
};

Maake sure to restart the bundler afterwards.

@artyorsh artyorsh reopened this Apr 28, 2020
@artyorsh artyorsh added 📚 Documentation 🐛 Bug and removed 🤷‍♂️ Needs info There is no enough info to resolve the issue labels Apr 28, 2020
@artyorsh artyorsh mentioned this issue Apr 28, 2020
2 tasks
@gabrielepmattia
Copy link

@kakavip yep, thanks for the details. I fixed that in d120d5d. This is an upcoming change anyway, but if you need to use it currently, this may achieved by modifying props like the migration guide says. Sorry for such type of issue.

@gabrielepmattia thanks for the details The commit above also gives some notes on this. The problem is you use metro configuration which creates a styles during the build time. customMapping property is not required in this case as it is completely ignored. What you can do is modifying your metro.config.js with.

const evaConfig = {
  evaPackage: '@eva-design/eva',
  customMappingPath: './path-to/custom-mapping.json', 
};

Maake sure to restart the bundler afterwards.

Perfect, now it's clear but metro.config.js is created automatically by the project template, I think it should pointed out in the docs as a side note that the custom mapping must not to be used in the ApplicationProvider, especially for newcomers as me! Thank you!

@artyorsh
Copy link
Collaborator

it should pointed out in the docs as a side note that the custom mapping must not to be used

That is what I did 🙌

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

No branches or pull requests

4 participants