react-native-paper icon indicating copy to clipboard operation
react-native-paper copied to clipboard

Icon not showing up when using react-native-web with Next.js

Open kenchoong opened this issue 6 years ago • 4 comments

I really love this library, but no matter what I tried, I just cant make it work in my project. I using react-native-web, with next.js. But in documentation look like dont have direct support with Next.js.

This is what I tried:

babel.config.js

module.exports = {
	presets: [
		["@babel/preset-env", { useBuiltIns: "usage" }],
		[ 'next/babel' ],
		"@babel/preset-react",
		"@babel/preset-flow",
		"@babel/preset-typescript"
	],
	plugins: [
		[ 'react-native-web', { commonjs: true } ],
		[
			'@babel/plugin-transform-runtime',
			{
				absoluteRuntime: false,
				corejs: false,
				helpers: true,
				regenerator: true,
				useESModules: true,
				version: '7.0.0-beta.0'
			}
		],
		'@babel/plugin-proposal-object-rest-spread',
		'@babel/plugin-transform-async-to-generator',
		'@babel/plugin-proposal-class-properties'
	]
};

In next.config.js where I transpile the module, it look like this:

const path = require('path');
const withFonts = require('next-fonts');
const withTM = require('next-transpile-modules')([
	'react-native-elements',
	'react-native-paper',
	'react-native-ratings',
	'react-native-vector-icons',
	'react-native-safe-area-view',
	'react-native-status-bar-height',
	'react-native-normalize'
]);

module.exports = withFonts(
	withTM({
		devIndicators: {
			autoPrerender: false
		},
		enableSvg: true,
		webpack: (config, { defaultLoaders }) => {
			config.resolve.alias = {
				...(config.resolve.alias || {}),
				// Transform all direct `react-native` imports to `react-native-web`
				'react-native$': 'react-native-web'
			};
			config.resolve.extensions.push('.web.ts', '.web.tsx', '.ts', '.tsx', '.web.js', '.web.jsx', '.js', '.jsx');
			config.resolve.modules = [ ...config.resolve.modules, path.resolve(__dirname, 'node_modules') ];
			config.resolve.symlinks = false;
			config.module.rules.push(
				{
					test: /\.(jpe?g|png|gif|svg)$/i,
					use: [ 'url-loader?limit=10000', 'img-loader' ]
				},
				{
					test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
					exclude: /node_modules/,
					loader: 'file-loader'
				},
				{
					test: /\.(woff|woff2)$/,
					exclude: /node_modules/,
					loader: 'url-loader?prefix=font/&limit=5000'
				},
				{
					test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
					exclude: /node_modules/,
					loader: 'url-loader?limit=10000&mimetype=application/octet-stream',
					include: path.resolve(__dirname, 'node_modules/react-native-vector-icons')
				},
				{
					test: /\.js$/,
					loader: "babel-loader",
					exclude: /node_modules[/\\](?!react-native-vector-icons|react-native-safe-area-view)/
				}
			);

			return config;
		}
	})
);

So I already transpile the react-native-paper and using the plugin for react-native-vector-icons library in my next.config.js and babel.config.js .

But end up no matter what icon I use, I get the result like this:

a12

My usage is like this:

import { Button } from 'react-native-paper';

<Button icon="camera" mode="contained" onPress={() => console.log('Pressed')}>
		Press me
</Button>

So my question is, is that any support to Next.js with react-native-web ? I didnt know what else I can do, anyone have any suggestion ??

react-native-paper 3.10.1

kenchoong avatar Jun 14 '20 18:06 kenchoong

Found the following packages mentioned in the issue, but couldn't find version numbers for them:

  • react-native-paper

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

github-actions[bot] avatar Jun 14 '20 18:06 github-actions[bot]

The icons are from the https://github.com/oblador/react-native-vector-icons library. You'll need to look into their docs or issues about how to use it Next.js.

satya164 avatar Jun 14 '20 18:06 satya164

@satya164 I did, but seem like they also didnt say in their docs.

kenchoong avatar Jun 14 '20 19:06 kenchoong

any updates on this

LouieSankey avatar Jul 12 '23 01:07 LouieSankey