react-native-css-modules icon indicating copy to clipboard operation
react-native-css-modules copied to clipboard

CSS is Not working on Web.

Open kiritm-nimblechapps opened this issue 6 years ago • 12 comments

Hi,

I have integration as follow the steps you provided but the after creating CSS file and apply on js file. it's working fine in the iOS device but not working on web.

My Code :

import React, { Component } from 'react'
import { ScrollView, StyleSheet, TouchableOpacity, Text, View } from 'react-native'
import styles from "./styles.css";


export default class Dashboard extends React.Component {
    render() {
        return (
            <View className={styles.container}>
                <Text className={styles.blue}>Blue Text</Text>
            </View>
        )
    }
}

OnWeb : Screenshot 2019-10-03 at 10 08 57 AM

OnIOS: Screenshot 2019-10-03 at 10 09 44 AM

Can you help me.

Thanks.

kiritm-nimblechapps avatar Oct 03 '19 04:10 kiritm-nimblechapps

hey @kiritnim!

I think that the problem is that the Web part is not properly set up. Do you have your project somewhere where I could have a look at it? For example a new Github repository?

Here are the docs for Web: https://github.com/kristerkari/react-native-css-modules/blob/master/docs/web-compatibility.md

...and here are the needed files/config from the example app:

  • Webpack config: https://github.com/kristerkari/react-native-css-modules-example/blob/master/webpack.config.js
  • Web index.js: https://github.com/kristerkari/react-native-css-modules-example/blob/master/index.web.js
  • Web index.html: https://github.com/kristerkari/react-native-css-modules-example/blob/master/index.html

kristerkari avatar Oct 03 '19 18:10 kristerkari

hey @kiritnim!

I think that the problem is that the Web part is not properly set up. Do you have your project somewhere where I could have a look at it? For example a new Github repository?

Here are the docs for Web: https://github.com/kristerkari/react-native-css-modules/blob/master/docs/web-compatibility.md

...and here are the needed files/config from the example app:

  • Webpack config: https://github.com/kristerkari/react-native-css-modules-example/blob/master/webpack.config.js
  • Web index.js: https://github.com/kristerkari/react-native-css-modules-example/blob/master/index.web.js
  • Web index.html: https://github.com/kristerkari/react-native-css-modules-example/blob/master/index.html

I am use Expo, and the app is start with App.js, So can you help me with expo app.

kiritm-nimblechapps avatar Oct 04 '19 03:10 kiritm-nimblechapps

I am use Expo, and the app is start with App.js, So can you help me with expo app.

kiritm-nimblechapps avatar Oct 04 '19 03:10 kiritm-nimblechapps

I see, I have not tested the Web compatibility with Expo. I can have a look at it and update the docs to have the instructions for Expo too.

kristerkari avatar Oct 04 '19 05:10 kristerkari

Okay. Thanks I wait for it.

kiritm-nimblechapps avatar Oct 04 '19 05:10 kiritm-nimblechapps

Hi @kristerkari

Even i am facing the same issue. I am using the expo. For web css styles are not loading but for mobile ( ios & android ) styles are loading properly. Could you please add the solution.

yyaswanth avatar Jul 06 '20 12:07 yyaswanth

Has anyone found a solution yet?

RobinS-S avatar Oct 17 '20 17:10 RobinS-S

Would be interested too. Any way of getting this to work in Expo Web?

PPillau avatar Aug 11 '21 20:08 PPillau

@yyaswanth @RobinS-S @PPillau I'm not using Expo myself, but I know that adding the support is a bit trickier at the moment since react-native-web dropped the support for using the className property.

What would probably be required to get it working with Expo Web:

  1. Patch react-native-web to bring back support for the className property.
  2. Add Webpack configuration to Expo that would use the Webpack (Web) css modules.

kristerkari avatar Aug 12 '21 09:08 kristerkari

So, is there anyone know how to solve it?

I use expo too, just follow the path from react-native official. 😂

sikaco avatar Sep 06 '22 17:09 sikaco

Any update on this?

JoeBoulton avatar Oct 20 '22 13:10 JoeBoulton

Any update on this?

Yes, please check https://github.com/kristerkari/react-native-css-modules/issues/37#issuecomment-1269678996

kristerkari avatar Oct 21 '22 07:10 kristerkari