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

Web Support V1 #6782

Closed
63 of 84 tasks
EvanBacon opened this issue Jan 16, 2020 · 65 comments
Closed
63 of 84 tasks

Web Support V1 #6782

EvanBacon opened this issue Jan 16, 2020 · 65 comments
Assignees
Labels
Platform: web Using Expo in the browser

Comments

@EvanBacon
Copy link
Contributor

EvanBacon commented Jan 16, 2020

Web support beta has been great, but it's time to make it production ready! Here I've outlined the steps required to creating a production ready system for building basic web apps with Expo (a stable MVP). There are also a few completed V2 features which we can move to another place after V1 is complete.

Navigation

This has elevated to its own category.

  • Examples
    • Next.js for web & React Navigation for native
    • React Router for web & React Navigation for native
    • Drawer Navigator example
    • Using Media Queries to change navigation
  • React Navigation
    • History support basic navigators
    • History support for nested navigators

PWA

Documentation

Testing

SDK

  • Add unavailability errors to any native functionality that doesn't exist on web
  • Support all basic primitive features in the Expo ecosystem
  • Improve React Native for web
    • Fix tree-shaking

V2

  • Improve React Native for web
    • Slider component
    • Momentum scroll events
    • Fixing tint Color bug on safari
  • Support extended ecosystem
  • Improve/Add experimental packages
    • bar code scanner
    • face detector
  • Support third-party SDK modules
    • expo-facebook
    • expo-google
    • Sentry
    • Amplitude
    • expo-apple-authentication
      • Merge react-apple-authentication into expo-apple-authentication
    • Branch
    • Facebook Ads
    • Push Notifications
    • Payments - Stripe - expo-payments-stripe

Custom Workflows

  • Support basic Gatsby
    • Document getting started
    • Using Expo SDK
    • Building for deployment
    • Example
  • Support basic Next.js
    • Document getting started
    • Using Expo SDK
    • Building for deployment
    • Example
  • Support basic Preact

V2

Tooling

Snack

  • Add web support

Client

  • Show running expo web processes and open to web browser
@EvanBacon EvanBacon added the Platform: web Using Expo in the browser label Jan 16, 2020
@EvanBacon EvanBacon pinned this issue Jan 17, 2020
@EvanBacon EvanBacon self-assigned this Jan 17, 2020
@alejomendoza
Copy link

Awesome video and updates! I couldn't use the Video component in web, couldn't tell if it was supported in SDK 36, docs say it is. Great work :)

@AltairTodescatto
Copy link

Very cool, cant wait to get more of this tool.

@opeologist
Copy link

@EvanBacon are there any plans to integrate Fast Refresh for web? i've seen some webpack plugins that give experimental support, but haven't had luck getting all the kinks worked out. excited to see you @ RNA in march! ^_^

@EvanBacon
Copy link
Contributor Author

@tehOPEologist expo/expo-cli#1498

@liming-developer
Copy link

Syntax Error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?
How can i solve it?

@AltairTodescatto
Copy link

AltairTodescatto commented Feb 14, 2020

@liming-developer You had to wrap all the elements rendered in a page into a single enclosing tag. Just put a <> ... </> around your code into the render. A div works just as fine

@ningacoding
Copy link

support for expo install @react-native-community/viewpager ??? on Web

@abduraufsherkulov
Copy link

ImagePicker doesn't work as expected. Even if I disable option base64, it still provides me base64 data instead of files object.

@ghost
Copy link

ghost commented Mar 9, 2020

if i using web browser to run..that way same android studio to run

@raarts
Copy link

raarts commented Mar 10, 2020

What are V1 and V2, do those relate to the Web support? Will there be a Web Support V2?

@nonotest
Copy link

I have created a small app with rnw, nextjs and navigation v5, it is very impressive.
Needs a little configuration but still. very good job!

Any chance we could add better support for react-native-maps in the ecosystem category?
It looks like the project needs some workaround with proptypes and requireNativeComponent usage. I couldn't find any web specific issue on their repo.

I haven't really been able to make it work so far but happy to help if needed

@EvanBacon
Copy link
Contributor Author

@nonotest, the expo fork of react-native-maps has partial web support for Leaflet. It's a lot of work to add providers so I am mostly prioritizing packages in the Expo ecosystem that I have more freedom to edit.

@raarts V1 is what we're working towards right now, V2 means it's on the roadmap but not a priority at the moment.

@RWOverdijk
Copy link

Yeeeees please. Does this include easier setup for useLinking? Because right now it's near impossible to set it up properly with nested routers and a correct history.

If so, I'll repeat my Yeeeees please 😄

@Mukulagarwal1980
Copy link

I have created a small app with rnw, nextjs and navigation v5, it is very impressive.
Needs a little configuration but still. very good job!

Any chance we could add better support for react-native-maps in the ecosystem category?
It looks like the project needs some workaround with proptypes and requireNativeComponent usage. I couldn't find any web specific issue on their repo.

I haven't really been able to make it work so far but happy to help if needed

Hello,
Have you implemented custom view for drawer navigation v5

@Mukulagarwal1980
Copy link

Hello,

I m getting below error when allow for permissions for push notification on web app.

You must provide owner and slug in app.json to use push notifications on web. Learn more: https://docs.expo.io/versions/latest/guides/using-vapid/.

Please provide solution if any body have
Thanks in advance

@Sunil-prajapati
Copy link

Hello to all,
I am facing below given problem someone suggests me the solution

37.0.0 is not a valid sdk version option are 35.0.0

@mufeez-amjad
Copy link

I keep getting when running expo start:web:

Module not found: Can't resolve 'react-native' in 'app/node_modules/react-native-svg/lib/module'

@pyrossh
Copy link

pyrossh commented Apr 27, 2020

@mufeez-amjad You might need this react-native-svg-transformer

@pyrossh
Copy link

pyrossh commented May 3, 2020

I've got history support for basic navigators done and working. I was using react-navigation@v4 as a reference. It allows to reload the url with state preserved as along as the screen params are simple objects.

import React, { useState, useRef, useEffect } from 'react';
import { Platform } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createBrowserHistory, createMemoryHistory } from 'history';
import * as queryString from 'query-string';
const history = Platform.OS === 'web' ? createBrowserHistory() : createMemoryHistory();

export const getActiveScreen = (state) => {
  const route = state.routes[state.index];
  if (route.state) {
    return getActiveScreen(route.state);
  }
  return { name: route.name, params: route.params };
};

export const getInitialScreen = (initial) => {
  if (Platform.OS === 'web') {
    const path = window.location.pathname.replace('/', '');
    const params = queryString.parse(window.location.search);
    return { name: path ?  path[0].toUpperCase() + path.slice(1) : initial, params };
  }
  return { name: initial, params: {} };
};

export const getUrl = (name, params) => {
  const query = queryString.stringify(params);
  return name[0].toLowerCase() + name.slice(1) + (query ? '?' + query : '');
};

export default WebNavigationContainer = ({ setNavigation, children }) => {
  const [currentScreen, setCurrentScreen] = useState(null);
  const navigationRef = useRef();
  useEffect(() => {
    if (navigationRef.current) {
      const state = navigationRef.current.getRootState();
      setCurrentScreen(getActiveScreen(state));
      setNavigation(navigationRef.current);
    }
    return history.listen((location, action) => {
      if (action === 'POP') {
        navigationRef.current.goBack();
      }
    });
  }, [navigationRef !== undefined && navigationRef !== null]);
  const onStateChange = (state) => {
    const nextScreen = getActiveScreen(state);
    if (currentScreen.name !== nextScreen.name) {
      if (!(nextScreen.name.indexOf('Navigator') > -1)) {
        let navigate = history.push;
        // if (currentScreen && currentScreen.name.indexOf('Navigator') > -1) {
        //   navigate = history.replace;
        // }
        const url = getUrl(nextScreen.name, nextScreen.params);
        navigate(url);
        setCurrentScreen(nextScreen);
      }
    }
  };
  return (
    <NavigationContainer ref={navigationRef} onStateChange={onStateChange}>
      {children}
    </NavigationContainer>
  );
};

export const WebNavigator = ({ Comp, screenOptions, initialRouteName, initialRouteParams, children, ...props }) => {
  return (
    <Comp screenOptions={screenOptions} initialRouteName={initialRouteName} {...props}>
      {React.Children.map(children, (child) => {
        const initialParams = initialRouteName === child.props.name ? initialRouteParams : {};
        return React.cloneElement(child, { initialParams });
      })}
    </Comp>
  );
};

Example:

import React, { useState } from 'react';
import { View, Text, Button } from 'react-native';
import { createStackNavigator } from '@react-navigation/stack';
import { WebNavigationContainer, WebNavigator, getInitialScreen } from './navigation';

const Home = ({ navigation }) => (
  <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
    <Text>Home</Text>
    <Button title="Login" onPress={() => navigation.navigate('Login', { email: 'abc' })} />
  </View>
);
const Login = ({ route: { params } }) => (
  <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
    <Text>Login</Text>
    <Text>Email: {params.email}</Text>
  </View>
);

const Stack = createStackNavigator();

export default function App() {
  const [navigation, setNavigation] = useState(null);
  const { name, params } = getInitialScreen('Home');
  return (
    <WebNavigationContainer setNavigation={setNavigation}>
      <WebNavigator Comp={Stack.Navigator} initialRouteName={name} initialRouteParams={params}>
        <Stack.Screen name="Home" component={Home} />
        <Stack.Screen name="Login" component={Login} />
      </WebNavigator>
    </WebNavigationContainer>
  );
}

here: https://github.com/pyros2097/components

@hyochan
Copy link
Contributor

hyochan commented May 16, 2020

Screen Shot 2020-05-16 at 10 16 04 PM

Is react-native-svg-transformer not working with expo-web?
I am facing the above error and trying to add below code by customizing webpack.

@hyochan
Copy link
Contributor

hyochan commented May 16, 2020

Ok customizing webpack as above didn't help. I've found the issue in react-native-svg-transformmer.

@pyrossh
Copy link

pyrossh commented May 16, 2020

@hyochan It works for me. I took this as an example https://github.com/kristerkari/react-native-svg-example. I had initial hiccups but it worked later on. This is my config.

const { getDefaultConfig } = require('metro-config');

module.exports = (async () => {
  const {
    resolver: { sourceExts, assetExts }
  } = await getDefaultConfig();
  return {
    transformer: {
      getTransformOptions: async () => ({
        transform: {
          experimentalImportSupport: false,
          inlineRequires: false
        }
      }),
      babelTransformerPath: require.resolve('react-native-svg-transformer')
    },
    resolver: {
      assetExts: assetExts.filter(ext => ext !== 'svg'),
      sourceExts: [...sourceExts, 'svg']
    }
  };
})();

and

"packagerOpts": {
      "config": "metro.config.js",
      "sourceExts": ["js", "jsx", "svg", "ts", "tsx"]
}
"react-native-svg": "9.13.3",
"react-native-svg-transformer": "^0.14.3",

@hyochan
Copy link
Contributor

hyochan commented May 16, 2020

@pyros2097 Wow! Thanks for sharing so quickly. I've also found the issue as I've posted above.

By the way, I am facing another problem in react-native-svg.
Screen Shot 2020-05-16 at 11 40 46 PM
Screen Shot 2020-05-16 at 11 41 02 PM

When I set the size manually, as shown above, the image is cut off instead of resizing.
Screen Shot 2020-05-16 at 11 42 35 PM

@OrlandoGareca
Copy link

info @expo/ngrok-bin-freebsd-x64@2.2.8: The platform "win32" is incompatible with this module.
info "@expo/ngrok-bin-freebsd-x64@2.2.8" is an optional dependency and failed compatibility check. Excluding it from installation.

problem library ngrok intall in windows 10

@brentvatne
Copy link
Member

@OrlandoGareca - no, that's not what is happening. this is just a warning that npm shows for optional packages, you will see it for macos and linux if you're using windows, you can ignore it.

@eguonzy
Copy link

eguonzy commented Oct 4, 2020

i opened my app via expo web and some layout attributes changed and it doesnt consume the api

@renegoretzka
Copy link

Image is not showing up in the web view, because its set to position: absolute; instead of position: relative; as it should be with react-native.

@gabriela-sartori
Copy link

react-native-modal-datetime-picker doesn't work for web

@brentvatne
Copy link
Member

@G4BB3R - that is unrelated to expo, you should post an issue on the react-native-modal-datetime-picker repository. we can't go around and update everybody's repos to support web, that is not feasible

@kaptenPrice
Copy link

expo start--web
Failed to compile

C:/.........../......../node_modules/react-navigation-stack/lib/module/views/Header/Header.js
Module not found: Can't resolve 'react-native-web/dist/exports/MaskedViewIOS' in 'C:.........\node_modules\react-navigation-stack\lib\module\views\Header'

@mahermassoud
Copy link

Looks like console.log() doesn't work for me for web but it does for iOS.

Meaning when I do a console.log() message, it shows up on the CLI when i open the app on my phone through tunnel, but it does not show up when I open as a web app (local or not). I'm on Mac OS 11.0.1 and using expo version 4.2.1

thanks

@brentvatne
Copy link
Member

brentvatne commented Mar 7, 2021

@mahermassoud - console.log on web goes to your browser developer tools logs. we show logs in expo-cli for ios and android because there is no equivalent to this in those cases. it's much better to use your developer tools logs than having to serialize and print the logs in expo-cli terminal. in other words, this is intentional, expected behavior. that said, if you think this is not desirable and would like to propose alternative behavior or some way for us to make this clear, let us know!

@mahermassoud
Copy link

@brentvatne OMG Thanks so much!!!!!!!!!!!

@nikurou
Copy link

nikurou commented Mar 9, 2021

Ran into a strange issue on the web version while going thru a Udemy RN course, hopefully others are able to replicate and its not just me. Basically, when you spread your style properties over a view like so...

<View style={{ ...styles.container, ...{ backgroundColor: props.color } }}>
    //some content
</View>

...generally the second style object you spread over will overwrite any overlapping properties of the first style object, but otherwise keeps all the style properties from the first (styles.container) that weren't overwritten by the second. While this works as intended on my android emulator in the screenshot below, the behavior in web seems to be that it decided to ditch the {styles.container} entirely, and only apply {backgroundColor: props.color}?

For reference the style of styles.container was:

container: {
    flex: 1,
    borderRadius: 10,
    shadowColor: "black",
    shadowOpacity: 0.26,
    shadowOffset: { width: 0, height: 2 },
    shadowRadius: 10,
    elevation: 3,
    padding: 10,
    justifyContent: "flex-end",
    alignItems: "flex-end",
    backgroundColor: "pink",
  },

Image:
image_2021-03-08_202414

@ianmartorell
Copy link

@nikurou I'm not sure why that works on native, but it's probably due to the fact that styles aren't actually objects, but optimized references, so you can't spread them. It will work if you use an array instead:

<View style={[styles.container, { backgroundColor: props.color }]}>
    //some content
</View>

@nikurou
Copy link

nikurou commented Mar 9, 2021

@ianmartorell Thanks! This totally works. As I said, I'm following off a React Native Udemy course, and spreading the style is what the instructor of that course taught. For all intents and purposes, it actually does work perfectly fine when viewed on both iOS and Android, just not on web, but I'll remember to do it your way from now on since it seems to work for web as well.

@marco2216
Copy link

Hi, I'm wondering what the status on Fast Refresh is? I tried following @EvanBacon's guide, but couldn't get anything working. I was also stuck on live reloading, couldn't find a way to disable that.

@vickneswarixbi4
Copy link

Hi, expo go app doesn't get reloading once a plugin is imported

@alaminsheikh01
Copy link

Hi, when I try to run my app as web then show me error like this:

C:/Users/alami/OneDrive/Desktop/React native/starter-react-native/node_modules/react-native-gesture-handler/Swipeable.js
Module not found: Can't resolve 'react-native-web/dist/exports/Animated' in 'C:\Users\alami\OneDrive\Desktop\React native\starter-react-native\node_modules\react-native-gesture-handler'```

Any idea please

@chackerian
Copy link

I'm getting a Failed to compile. Invalid file signature error. When any part of the page is changed and it re renders, it loads properly. I'm not sure what is causing this issue.

@raulvictorrosa
Copy link

When using theme props of styled-components is not working on web.

Example bellow is returning error.

export const Title = styled.Text`
  color: ${({theme}) => theme.colors.secondary};
  font-family: ${({theme}) => theme.fonts.boldTitle};
  font-size: ${RFValue(32)}px;
  margin-bottom: 28px;
  line-height: 32px;
`;

Is returning the following error.
TypeError: Cannot read property 'secondary' of undefined
TypeError: Cannot read property 'boldTitle' of undefined

@mariomurrent-softwaresolutions
Copy link
Contributor

I'm getting the following error, when I try to start my app with expo web:

Failed to compile.
/Users/.../node_modules/react-native/Libraries/Components/TextInput/TextInputState.js
Module not found: Can't resolve '../../Utilities/Platform' in '/Users/.../node_modules/react-native/Libraries/Components/TextInput'

And I'm also getting this error from time to time:

Failed to compile.
/Users/.../node_modules/expo-analytics/node_modules/expo-constants/build/ExponentConstants.web.js
Module not found: Can't resolve 'uuid/v4' in '/Users/.../node_modules/expo-analytics/node_modules/expo-constants/build'

Any idea how to solve this?

@GustavoEklund
Copy link

GustavoEklund commented Jul 16, 2021

I'm getting the following error, when I try to start my app with expo web:

/node_modules/react-native/Libraries/LogBox/UI/LogBoxNotification.js
Module not found: Can't resolve '../../Image/Image' in '/node_modules/react-native/Libraries/LogBox/UI'

@prithvi-jpg

This comment has been minimized.

@JudiPuak
Copy link

Hi all:

Please excuse my ignorance.

When I run my app on Android, deep linking to calendar, phone dialer, and web browser works fine.
However, when I run it on web, none of the above works.
Is this the correct behavior or is my app missing something?
I use SDK39.

Perhaps, I need to use SDK 42 to make it work?
Or perhaps it's a future feature?

Thank you.

Judi

@mogarick
Copy link

Hi all:

Please excuse my ignorance.

When I run my app on Android, deep linking to calendar, phone dialer, and web browser works fine.
However, when I run it on web, none of the above works.
Is this the correct behavior or is my app missing something?
I use SDK39.

Perhaps, I need to use SDK 42 to make it work?
Or perhaps it's a future feature?

Thank you.

Judi

@JudiPuak remember that v 39 is gonna be deprecated in the next release. It would be a good idea to create a new branch in your project and test v42.

Our next release is planned for September/October 2021 and, at that time, we’ll be dropping support for SDK 39. If your project is running on SDK 39, consider upgrading to a newer version in the coming months.

Here is the link: https://blog.expo.dev/expo-sdk-42-579aee2348b6

@cronwel
Copy link

cronwel commented Jul 30, 2021

Hello Expo Team:
Issue: Expo Web broken, does not emulate
Sequence:

  1. ran npm start
  2. received prompt to install update for expo npm install -g expo-cli
  3. reran npm start after installing new expo-cli`
  4. pressed w for web interface
  5. received error message below:

Failed to complie.
/Users/RBI/13-RFNK/node_modules/@react-navigation/native/lib/module/Themed.js
Module not found: Can't resolve '@react-navigation/core' in '/Users/RBI/13-RFNK/node_modules/@react-navigation/native/lib/module'

Comments:
I'm looking right at the package, following the path.
Not familiar with this type of issue, please let me know if there is something I can do to get it working again. Thanks for all you do!

@EvanBacon
Copy link
Contributor Author

@cronwel please open an issue on https://github.com/react-navigation/react-navigation instead.

@EvanBacon
Copy link
Contributor Author

We'll be upgrading to react-native-web@~0.17.1 for Expo SDK 43! Here are the base differences in case you want to update your app accordingly: necolas/react-native-web@0.13.17...0.17.1

@Maker-Mark
Copy link

@EvanBacon Is there a predictable way to get the URL history even though page refresh, or is async storage the best way to go?

@EvanBacon
Copy link
Contributor Author

@Maker-Mark that question seems better suited for stack overflow, this issue is simply for progress tracking.

@EvanBacon
Copy link
Contributor Author

I'm marking this issue as complete since all of the V1 tasks are done. Expo SDK components, and APIs are stable on web.

The tooling in Expo CLI (expo/webpack-config) should still be considered beta as it's not cross-platform and doesn't share enough with iOS and Android -- ideally we'd have some kinda Webpack for iOS and Android, or metro for web. This has been held up by native platform restrictions that I've been working on for a while like code splitting on native.

If you use Expo SDKs with another Webpack config like the Next.js Webpack config, then it should be stable enough for production.

I'll continue working on the bundler over in the expo/expo-cli repo (things like Webpack 5 upgrade), and update the CLI warning to more specifically point to Webpack support as being the feature that is still in beta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: web Using Expo in the browser
Projects
None yet
Development

No branches or pull requests