Vue-FontAwesome: How to import all Free and Pro Icons? Duplicate declaration error - vue.js

I own a FontAwesome Pro License and I use the Vue-FontAwesome Component.
When I try to import all icons from both the free and Pro repo I get an "Duplicate declaration error ..." and if I change the declaration name it can't be found anymore.
import { library } from '#fortawesome/fontawesome-svg-core'
import { fab } from '#fortawesome/free-brands-svg-icons'
import { fas } from '#fortawesome/pro-solid-svg-icons'
import { far } from '#fortawesome/pro-regular-svg-icons'
import { fal } from '#fortawesome/pro-light-svg-icons'
import { fas } from '#fortawesome/free-solid-svg-icons'
import { far } from '#fortawesome/free-regular-svg-icons'
library.add(fab)
library.add(fas)
library.add(far)
library.add(fal)
How do I import all icons from Free and Pro?

I tried to add Fontawesome pro icons to Vuetify(1.5.x). I found a solition. I share this solution with you.
First of all, in your project directory, create a file called .npmrc and add this to it:
#fortawesome:registry=https://npm.fontawesome.com/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX,
install fontawesome-pro package with npm or yarn
npm install --save-dev #fortawesome/fontawesome-pro
or
yarn add --dev #fortawesome/fontawesome-pro
Add this line in app.js or main.js
import '#fortawesome/fontawesome-pro/css/all.css'
Install pro icon packages
npm i --save #fortawesome/pro-solid-svg-icons
npm i --save #fortawesome/pro-regular-svg-icons
npm i --save #fortawesome/pro-light-svg-icons
You can use with pro icons with prefix (fas solid, far regular fal light. That's all you can use pro icons. I hope work with your project. Good Luck.

You're in effect importing multiple icon packs into to the same var for both far and fas, hence the error "Duplicate declaration".
As stated in comments, if you have FontAwesome Pro, that includes everything in FontAwesome Free. Import the pro-packages you need, and forget about the free edition.
That being said, importing the entire thing isn't ideal. If you're using a bundle manager with tree shaking (i.e webpack), it will save your application's weight impact tenfold. You rarely need all of the 5k icons.
Continuing down that road, that is; not importing the entire package: You can import different icon versions by importing and casting them. Like so:
import { library } from '#fortawesome/fontawesome-svg-core'
import { faCoffee as fasCoffee } from '#fortawesome/pro-solid-svg-icons'
import { faCoffee as farCoffee } from '#fortawesome/pro-regular-svg-icons'
import { faCoffee as falCoffee } from '#fortawesome/pro-light-svg-icons'
library.add(fasCoffee, farCoffee, falCoffee)
More on all of this in the official docs for FA-Pro.

Related

How to depricated Fix import { Plugins } from '#capacitor/core';

Does anyone know what is the fix for the decricated import of ionic Plugins?
I'm following a tutorial and I cant proceed until I fix it..
i used plugin
npm install capacitor-face-id
Enter link description here
import { Plugins, PluginResultError } from '#capacitor/core';
const { FaceId } = Plugins;
Many thanks
I assume you are using Capacitor 3.
This plugin seems to be compatible only with Capacitor 2 (see issue #181).
In Capacitor 2 this import type is used.

How to suppress a specific warning in expo

I am getting below warning
AsyncStorage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '#react-native-async-storage/async-storage' instead of 'react-native'. See https://github.com/react-native-async-storage/async-storage
How can I suppress it?
I have tried the below method(placed below lines in app.js) but none are working.
import { LogBox } from 'react-native'
LogBox.ignoreLogs(['Warning: AsyncStorage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from `#react-native-async-storage/async-storage` instead of `react-native`. See https://github.com/react-native-async-storage/async-storage'])
import { LogBox } from 'react-native'
LogBox.ignoreLogs(["Warning: AsyncStorage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '#react-native-async-storage/async-storage' instead of 'react-native'. See https://github.com/react-native-async-storage/async-storage"])
Can anyone help me to suppress it?
import { LogBox } from 'react-native';
LogBox.ignoreLogs(['Asyncstorage: ...']); // Ignore log notification by message
LogBox.ignoreAllLogs(); //Ignore all log notifications
Its a warning. Do not suppress it. I guess you are using Async storage from 'react-native' package. Instead install #react-native-async-storage/async-storage and use it from here.

Unable to resolve module 'react-redux'...module 'react-redux' does not exist in haste module map

The code in app.js file with import statements for react redux is created to display a header with a text called "Tech stack".
App.js
import React from 'react';
import { View } from 'react-native';
import { Header } from './components/common';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducers from './reducers';
const App = () => {
return(
<Provider store={createStore(reducers)}>
<View>
<Header headerText="Tech Stack" />
</View>
</Provider>
);
};
export default App;
This is the index file
index.js
import { AppRegistry } from 'react-native';
import App from './src/App';
AppRegistry.registerComponent(tech_stack, () => App);
While running this on the terminal, it throws a error saying unable to resolve module 'react-redux'.
Close the JS bundle(a terminal starts when you run app for first time) and rerun it using the command react-native start from the project path. Basically, you need to rerun the JS bundle after every package installation.
Install 'react-redux' by using
npm install --save react-redux
if you not installed it. By seeing your comment as you mentioned that you installed redux only.
Then restart the JS bundle by using
react-native start --reset-cache
I've faced this issue just now. actually, Our (you and I) main issue is naming the global state folder name is redux and the bundler falls in a conflict because there is a folder inside node_modules that name is redux too.
In fact, the main issue is this line:
import { createStore } from 'redux';
I renamed the resux stuffs folder to reduxStore instead of redux and then everything works properly.
This error occurs because you do not have Redux-Thunk middleware installed on your application. To install run:
npm install redux-thunk
Then, restart your application:
react-native start
More information: https://github.com/reduxjs/redux-thunk
I just ran into this problem and solved it by installing redux in addition to react-redux. Apparently, react-redux requires it.

Read app.json (or exp.json) programmatically

Is there a way to read the contents of app.json programmatically from within you app, so you could for example get the current version number and show it within an About screen?
You can access this through Constants.manifest. This includes your app.json config without any of the potentially sensitive information such as API secret keys.
import Constants from 'expo-constants';
Constants.manifest.version
For Expo SDK 35, I did this:
expo install expo-constants
in your .js:
import Constants from "expo-constants";
<Text> {Constants.manifest.description} </Text>
For expo SDK 33 use:
import Constants from "expo-constants";
{`v${Constants.manifest.version}`}
npm:
npm install expo-constants
OR
expo:
expo install expo-constants
About.js
import Constants from "expo-constants";
<Text>Version {Constants.manifest.version} </Text>
As of Expo SDK 46, use Constants.expoConfig. Source: https://github.com/expo/expo/discussions/17176
Newer versions of expo (I'm on 36) now import the variable differently
import Constants from 'expo-constants';
Read all about it here on the expo documentation site
When trying to use this line
import { Constants } from 'expo-constants';
Constants was showing up as undefined when logged to the console.
However, this code worked to display the app's version:
<template>
<text>version: {{ appVersion }}</text>
</template>
<script>
import * as Constants from 'expo-constants';
export default {
data() {
return {
appVersion: Constants['default']['manifest']['version']
}
}
}
</script>

How do I fix RN suddenly being unable to find local modules (Unable to resolve module)?

I've got a strange situation where suddenly my RN app won't load any of its scenes. The app has been running fine for weeks and I haven't moved any of the files. The failure:
error: bundling: UnableToResolveError: Unable to resolve module `./src/scenes/splash` from `/Users/jcollum/projects/starsApp/index.ios.js`: Directory /Users/jcollum/projects/starsApp/src/scenes/splash doesn't exist
at Promise.resolve.then (/Users/jcollum/projects/starsApp/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:445:15)
at process._tickCallback (internal/process/next_tick.js:109:7)
My import statements look like:
import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View } from 'react-native';
import { Router, Scene } from 'react-native-router-flux';
import Icon from 'react-native-vector-icons/FontAwesome';
import Splash from './src/scenes/splash';
The scene definitely exists:
$ ll /Users/jcollum/projects/starsApp/src/scenes/splash.js
-rw-r--r-- 1 jcollum staff 722B Apr 26 10:12 /Users/jcollum/projects/starsApp/src/scenes/splash.js
And it has an export default:
import React, { Component, PropTypes } from 'react';
import { View, Text, TouchableHighlight, Image } from 'react-native';
import styles from '../styles'
import { Actions } from 'react-native-router-flux';
export default class Splash extends Component {
componentWillMount() {
setTimeout(() => {
Actions.Home()
}, 1000);
}
render() {
console.log(`rendering Splash`);
return (
<View ...
Things I have tried:
restarting packager
resetting content and settings
checking out a previous commit
clearing temp dir: rm -fr $TMPDIR/react-*
react-native --version
react-native-cli: 2.0.1
react-native: 0.43.2
What could be causing this? Why would this suddenly stop loading resources? What's the next thing to try?
Solution (don't know why this works, sorry):
Stop any running packager
Add this to package.json: "clean-start": "rm -rf node_modules && yarn install && rm -rf $TMPDIR/react* && npm start --reset-cache", (or npm install if you don't use yarn)
npm run clean-start
I faced the similar issue once and what i did was nothing fancy, I just cut all the files which were giving error and copied at some place(outside my project dir) and then paste those files again at their place helped me..
Cheers :)
In my case, ran
npm cache verify
in console at my project directory, all was well. Hope it helps