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

This package is not working #3

Closed
udemezue01 opened this issue Sep 27, 2021 · 9 comments
Closed

This package is not working #3

udemezue01 opened this issue Sep 27, 2021 · 9 comments

Comments

@udemezue01
Copy link

I tried using this package, on my package and I did not get this to work.

@kasinskas
Copy link
Owner

I'm sorry, but it's hard to understand what is wrong based on what you wrote. Could you elaborate? I'm using this package myself on several projects without any issues.

@udemezue01
Copy link
Author

I will show my code.

I wanted to create responsiveness based on a certain screen type here is my code.


import { StatusBar } from 'expo-status-bar';
import React from 'react';
import {SafeAreaView, View, Text, Button, Image} from 'react-native';
import StyleSheet from 'react-native-media-query';

import tailwind from 'tailwind-rn';



const Landing= ({navigation}) => {
  return (
    <SafeAreaView style={[styles.container, tailwind('bg-gray-50 h-full')]} >


      {/* The container */}
		<View style={tailwind('bg-white h-full rounded-lg justify-center px-4')}>


        <Image source={require('../../assets/ufarmlogo.png')}
              style={tailwind('flex flex-row h-full w-full object-cover object-center justify-center items-center')}
        />


          <View style={tailwind('mt-24')}> 
    
          <Text 

          onPress={() => navigation.navigate('Register')}

          style={[styles.btn, tailwind('py-3 px-3 rounded-md font-black text-lg tracking-wider text-center text-white')]} > 

          Get started
          </Text>

            </View>
            
		</View>

    {/* End of the container */}
	</SafeAreaView>
  );
}
const styles = StyleSheet.create({
  container: {
   
    paddingLeft:550,
    paddingRight:550,
    '@media (max-width: 200px)': {
      paddingLeft:350,
      paddingRight:350,
  },

  '@media (max-width: 200px)': {
    paddingLeft:50,
    paddingRight:50,
},

  },

  btn: {
   
    backgroundColor:'#72A320',

  },
 
});

export default Landing

@udemezue01
Copy link
Author

I wanted to set the padding based on the media queries, but unfortunately it did not work

@kasinskas
Copy link
Owner

So what exactly is not working? I assume this is mobile and not web? What's the size of the device and what styles are being applied?

@kasinskas
Copy link
Owner

First of all StyleSheet.create returns an object that contains ids that are used on web and actual styles.

const {ids, styles} = StyleSheet.create

This is mentioned in the readme - https://github.com/kasinskas/react-native-media-query#usage

Secondly, your @media rules have the same max-width.

@udemezue01
Copy link
Author

So what exactly is not working? I assume this is mobile and not web? What's the size of the device and what styles are being applied?

This is react native web, I am developing a web app

@udemezue01
Copy link
Author

First of all StyleSheet.create returns an object that contains ids that are used on web and actual styles.

const {ids, styles} = StyleSheet.create

This is mentioned in the readme - https://github.com/kasinskas/react-native-media-query#usage

Secondly, your @media rules have the same max-width.

I will try it out and see, I wanted to have many media query perform various styles.

@kasinskas
Copy link
Owner

So what exactly is not working? I assume this is mobile and not web? What's the size of the device and what styles are being applied?

This is react native web, I am developing a web app

Well then you're also missing dataSet (or data-media depending on your rn-web version) prop. It's also mentioned in the readme, please have a look.

@udemezue01
Copy link
Author

Thanks, I will check and get back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants