![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
@native-base/icons
Advanced tools
Readme
This project was designed to make integration of icons in nativebase projects easier. It is a unified library which export icons and fonts for all the native and web platforms.
yarn add @native-base/icons
Add Fonts:
_document.js
import { default as NativebaseDocument } from "@native-base/next-adapter/document";
import fontsCSS from "@native-base/icons/FontsCSS"
import { AppRegistry } from "react-native";
import { Main } from "next/document";
import * as React from "react";
class Document extends NativebaseDocument {
//
}
async function getInitialProps({ renderPage }) {
AppRegistry.registerComponent("Main", () => Main);
const { getStyleElement } = AppRegistry.getApplication("Main");
const page = await renderPage();
const styles = [
// eslint-disable-next-line react/jsx-key
<style dangerouslySetInnerHTML={{ __html: fontsCSS }} />,
getStyleElement(),
];
return { ...page, styles: React.Children.toArray(styles) };
}
Document.getInitialProps = getInitialProps;
export default Document;
_document.js
)
import { default as NativebaseDocument } from "@native-base/next-adapter/document";
import AntDesignFontFaceCSS from "@native-base/icons/FontsCSS/AntDesignFontFaceCSS";
import MaterialIconsFontFaceCSS from "@native-base/icons/FontsCSS/MaterialIconsFontFaceCSS";
const fontsCSS = AntDesignFontFaceCSS + MaterialIconsFontFaceCSS;
class Document extends NativebaseDocument {
//
}
async function getInitialProps({ renderPage }) {
const res = await NativebaseDocument.getInitialProps({ renderPage });
const styles = [
// eslint-disable-next-line react/jsx-key
<style dangerouslySetInnerHTML={{ __html: fontsCSS }} />,
...res.styles
];
return { ...res, styles: React.Children.toArray(styles) };
}
Document.getInitialProps = getInitialProps;
export default Document;
Update next.config.js
with this code (if you are using @native-base/next adapter):
const { withNativebase } = require("@native-base/next-adapter");
const path = require("path");
module.exports = withNativebase({
dependencies: ["@native-base/icons"],
nextConfig: {
webpack: (config, options) => {
config.module.rules.push({
test: /\.ttf$/,
loader: "url-loader", // or directly file-loader
include: path.resolve(__dirname, "node_modules/@native-base/icons"),
});
config.resolve.alias = {
...(config.resolve.alias || {}),
"react-native$": "react-native-web",
};
config.resolve.extensions = [
".web.js",
".web.ts",
".web.tsx",
...config.resolve.extensions,
];
return config;
},
},
});
Add Fonts:
index.jsx/index.tsx
:
import fontsCSS from "@native-base/icons/FontsCSS";
const style = document.createElement("style");
style.type = "text/css";
style.appendChild(document.createTextNode(fontsCSS));
document.head.appendChild(style);
import AntDesignFontFaceCSS from "@native-base/icons/FontsCSS/AntDesignFontFaceCSS";
import MaterialIconsFontFaceCSS from "@native-base/icons/FontsCSS/MaterialIconsFontFaceCSS";
const fontsCSS = AntDesignFontFaceCSS + MaterialIconsFontFaceCSS;
const style = document.createElement("style");
style.type = "text/css";
if (style.styleSheet) {
style.styleSheet.cssText += fontsCSS;
} else {
style.appendChild(document.createTextNode(fontsCSS));
}
document.head.appendChild(style);
.babel.config.js
file in root directory:
module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
plugins: [
[
"module-resolver",
{
alias: {
"@native-base/icons": "@native-base/icons/lib",
},
},
],
],
};
};
Now, let’s render an icon:
import { Entypo } from "@native-base/icons";
return <Icon as={Entypo} name="user"></Icon>;
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)FAQs
## **Table of Contents**
We found that @native-base/icons demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.