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

borderStyle: 'dashed' doesn't work correctly

Open TohsakaHaku opened this issue 3 years ago • 11 comments

Description

Dear Developers: I am trying to control the style of View. When 'Dashed' pressed, the style of View will be changed, especially the borderStyle will be set as 'dashed'.

The problem is, when I run this on iOS devices, the dashed border line and the solid border line are coexisted. It only appears when overflow is set as 'hidden'

image

Waiting for your answer : )

import React, { useState } from 'react';
import { Text, View, StyleSheet } from 'react-native';

const styles = StyleSheet.create({
  item: {
    width: 100,
    height: 100,
    borderWidth: 1,
    borderColor: 'gray',
    borderRadius: 4,
    overflow: 'hidden'
  },
  addItem: {
    width: 100,
    height: 100,
    borderWidth: 3,
    borderColor: 'red',
    borderRadius: 4,
    borderStyle: 'dashed',
    overflow: 'visible'
  }
})

const HelloWorldApp: React.FC = () => {
  const [st, setSt] = useState(styles.item)
  return (
    <View
      style={{
        flex: 1,
        justifyContent: "center",
        alignItems: "center"
      }}>
      <Text>Hello, world!</Text>
      <View style={st}/>
      <Text onPress={() => {
        setSt(styles.addItem)
      }}>Dashed</Text>
      <Text onPress={() => {
        setSt(styles.item)
      }}>Reset</Text>
    </View>
  )
}
export default HelloWorldApp;

Version

0.66.00

Output of npx react-native info

I dont have any info because I reproduced this problem on reactnative.dev/docs/tutorial

Steps to reproduce

You can paste code here reactnative.dev, where I met this problem.

Run with iOS device and click the 'Dashed' Text, you will met same problem, I think.

import React, { useState } from 'react';
import { Text, View, StyleSheet } from 'react-native';

const styles = StyleSheet.create({
  item: {
    width: 100,
    height: 100,
    borderWidth: 1,
    borderColor: 'gray',
    borderRadius: 4,
    overflow: 'hidden'
  },
  addItem: {
    width: 100,
    height: 100,
    borderWidth: 3,
    borderColor: 'red',
    borderRadius: 4,
    borderStyle: 'dashed',
    overflow: 'visible'
  }
})

const HelloWorldApp: React.FC = () => {
  const [st, setSt] = useState(styles.item)
  return (
    <View
      style={{
        flex: 1,
        justifyContent: "center",
        alignItems: "center"
      }}>
      <Text>Hello, world!</Text>
      <View style={st}/>
      <Text onPress={() => {
        setSt(styles.addItem)
      }}>Dashed</Text>
      <Text onPress={() => {
        setSt(styles.item)
      }}>Reset</Text>
    </View>
  )
}
export default HelloWorldApp;

Snack, code example, screenshot, or link to a repository

No response

TohsakaHaku avatar Jan 19 '22 06:01 TohsakaHaku

+1

dirkpostma avatar May 26 '22 05:05 dirkpostma

+1

m2hd1 avatar May 26 '22 14:05 m2hd1

To add to this, if you set borderRadius > 0 the gray outline disappears

sseppola avatar Jun 01 '22 09:06 sseppola

The borderStyle when not equal to solid still behaves wrongly (using React Native 0.68.2 and Expo 45.0.6). The following code works when using solid and doesn't work when using dashed or dotted:

const styles = StyleSheet.create({
  row: {
    borderColor: '#000000',
    borderStyle: 'solid',
    borderTopWidth: 0,
    borderWidth: 1,
  },
});

aike19115 avatar Sep 06 '22 19:09 aike19115

+1

sisundin avatar Jun 28 '23 11:06 sisundin

This still doesn't work correctly

educbraga avatar Sep 10 '23 17:09 educbraga

+1

cunguyendev avatar Dec 08 '23 03:12 cunguyendev

+1

amitchaudhary140 avatar Dec 27 '23 09:12 amitchaudhary140

+1

pavlof01 avatar Feb 15 '24 22:02 pavlof01

+1

54m1r avatar Feb 17 '24 20:02 54m1r

+1

okevino47 avatar Jul 05 '24 13:07 okevino47

+1

wassimAJ avatar Jul 26 '24 09:07 wassimAJ