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

[Pressable] Styles are not applied #2979

Closed
m-bert opened this issue Jul 4, 2024 · 0 comments · Fixed by #2982
Closed

[Pressable] Styles are not applied #2979

m-bert opened this issue Jul 4, 2024 · 0 comments · Fixed by #2982
Assignees
Labels
Area: Pressable Maintainer issue Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: Web

Comments

@m-bert
Copy link
Contributor

m-bert commented Jul 4, 2024

Description

Some of CSS styles do not work with Pressables. It happens because style property is applied to outer View and not the button itself

image

Steps to reproduce

Test on the following code
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Pressable } from 'react-native-gesture-handler';

const onPressCallback = (type: string) =>
  console.log(`${type} pressable onPress`);

const onPressInCallback = (type: string) =>
  console.log(`${type} pressable onPressIn`);

const onPressOutCallback = (type: string) =>
  console.log(`${type} pressable onPressOut`);

export default function App() {
  return (
    <View style={styles.container}>
      <Pressable
        onPress={() => onPressCallback('outer')}
        onPressIn={() => onPressInCallback('outer')}
        onPressOut={() => onPressOutCallback('outer')}
        style={styles.outerPressable}>
        <View style={styles.box} />
      </Pressable>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },

  outerPressable: {
    width: 150,
    height: 150,
    backgroundColor: 'lightpink',

    display: 'flex',
    justifyContent: 'center',
    alignItems: 'center',
  },

  box: {
    width: 100,
    height: 100,
    backgroundColor: 'plum',
  },
});

Snack or a link to a repository

Irrelevant

Gesture Handler version

2.17.1

React Native version

0.74.1

Platforms

Android, iOS, Web

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

@m-bert m-bert added Platform: Web Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Maintainer issue Area: Pressable labels Jul 4, 2024
@m-bert m-bert changed the title [Pressable] flex styles are not applied [Pressable] Styles are not applied Jul 4, 2024
@latekvo latekvo closed this as completed in 1256081 Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Pressable Maintainer issue Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: Web
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants