Conversation
d3618f4 to
f8bf028
Compare
f8bf028 to
b56b154
Compare
1624696 to
040fb27
Compare
040fb27 to
b85b120
Compare
|
This works for me, for rendering a map. Just to clarify, there is currently only support for I can look into contributing, but no promises how much I'll be able to do. |
|
An alternative approach that might be more efficient for some is to use platform specific code for your map component, and write a separate map component for web and native. If you do all the data and state handling in parent component, you'll have very little to implement twice. https://reactnative.dev/docs/platform-specific-code#native-specific-extensions-ie-sharing-code-with-nodejs-and-web |
|
@mfazekas What is the state of this feature? I'm wondering if I should either invest time in doing what @localjo suggested but if there is a way to better share code I would gladdly use it. @localjo could you give an implementation example of your web map? I'm currently trying to test porting a react-native app that has a lot of maps in it. I'm using Nextjs and react-native-web. ├── package.json
├── node_modules
├── ios
├── android
├── web
│ ├── package.json
│ ├── node_modules
│ ├── config.next.js
│ └── pagesMy setup next config looks a bit like this: // next.config.js
const path = require('path');
const packageJson = require('../package.json');
const withTM = require('next-transpile-modules');
const withImages = require('next-images');
const modulesToTranspile = [
...Object.keys(packageJson.dependencies).filter((dep) =>
dep.startsWith('react-native')
),
];
/** @type {import('next').NextConfig} */
const configuration = {
transpilePackages: modulesToTranspile,
compiler: {
removeConsole: process.env.NODE_ENV === 'production',
},
images: {
disableStaticImages: true,
},
webpack: (
config,
{ buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }
) => {
config.resolve.alias = {
...(config.resolve.alias || {}),
'react-native$': 'react-native-web',
'react-native-vector-icons/': 'react-native-vector-icons/dist/',
'react-native-linear-gradient': 'react-native-web-linear-gradient',
};
config.resolve.extensions = [
'.web.js',
'.web.ts',
'.web.tsx',
...config.resolve.extensions,
];
config.module.rules.push({
test: /\.ttf$/,
loader: 'url-loader',
include: path.resolve(
__dirname,
'../node_modules/react-native-vector-icons'
),
});
config.plugins.push(
new webpack.DefinePlugin({
__DEV__: dev,
})
);
return config;
},
};
module.exports = withImages(withTM(modulesToTranspile)(configuration));So I only add to change this: const modulesToTranspile = [
+ '@rnmapbox/maps',
...Object.keys(packageJson.dependencies).filter((dep) =>
dep.startsWith('react-native')
),
];I didn't manage to install error - ../node_modules/@rnmapbox/maps/javascript/web/MapboxModule.js:1:0
Module not found: Can't resolve 'mapbox-gl'But if I add |
|
@cglacet it's a proof of concept as this time. It's merged, but it's not really usefull at the moment. Waiting for community contributions... |
|
@mfazekas Peole at mapbox are still puting efforts in this repository or is this only maintained by benevolent people? (are they willing to support any work that is made here?) |
|
@mfazekas Do you know if there is a plan to move this? |
|
@Ramon-Balaguer this has been merged. There were some contributions so it's slowly improving. https://rnmapbox.github.io/example-app/ Is the current example app. |
Rebase of #861, this is just a POC.
Structure:
package.json/browserpoints toindex.web.jswhich the loads content formjavascript/webdirectory that contains separate implementation of rnmapbox/maps on the mapbox-gl js api.To consume:
Extra steps for web:
rnmapbox/mapsis transpiled.@expo/webpack-configauto transpires packages starting withreact-native-butrnmapboxhas not `react-native in it's name, so it will not be transpired. See [Web] Work well in My Project ,but get errorModule parse failed: Unexpected tokenin module expo/expo-cli#3744 (comment) and https://github.com/expo/expo-cli/tree/master/packages/webpack-config#include-modules :