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

BorderShadow

Open williamdwarke opened this issue 6 years ago • 7 comments

Has anyone managed to get BorderShadow to work? I've tried it a dozen different ways and nothing seems to display properly. Most of the time my contained view completely disappears. If someone could post a working BorderShadow example I'd be extremely grateful. For context, I'm trying to set up an inset shadow on an input field and this looks like my only option.

williamdwarke avatar Apr 19 '18 23:04 williamdwarke

I am having the same issue, trying to generate border shadow with inset as true, it is not rendering the content, also giving a warning "Each child in an array or iterator should have a unique "key" prop.. "

muhammadasjadamin avatar Jun 23 '18 23:06 muhammadasjadamin

Add 'key' props to the 'Svg' component inside the node-modules -> react-native-shadow -> lib -> 'BorderShadow.js' file and all the children to BorderShadow component inside the app where you are using it.

ajaykumar97 avatar Jan 10 '19 09:01 ajaykumar97

You should give an array of children instead of a simple children

ethaqnix avatar Jul 24 '19 16:07 ethaqnix

in my case I had to give more than 1 children, because of not iterable issue

CyxouD avatar Oct 18 '19 11:10 CyxouD

Add 'key' props to the 'Svg' component inside the node-modules -> react-native-shadow -> lib -> 'BorderShadow.js' file and all the children to BorderShadow component inside the app where you are using it.

Could you please give me an example?

changyu2hao avatar May 29 '20 18:05 changyu2hao

A neat and clean implementation:

import React, { PureComponent } from 'react'
import { Text, View, Dimensions } from 'react-native'
import { BorderShadow } from 'react-native-shadow';

const { width } = Dimensions.get('window');

export default class Example extends PureComponent {
  render() {
    const tabShadowOpt = {
      width,
      height: 80,
      color: 'black',
      border: 5,
      radius: 1,
      opacity: 0.6,
      x: 0,
      y: 5,
      style: {},
      side: 'top',
    };
    return (
      <View style={{ flex: 1, justifyContent: 'flex-end' }}>
        <BorderShadow setting={tabShadowOpt}>
          {[ //the main idea is to pass child in an array
            <View
              style={{
                width,
                height: 80,
                backgroundColor: 'black',
                alignItems: 'center',
                justifyContent: 'center'
              }}
            >
              <Text style={{ color: 'white' }}> textInComponent </Text>
            </View>
          ]}
        </BorderShadow>
      </View>
    )
  }
}


BorderShadow expects array of children instead of a single child. Hope this would help you.

ajaykumar97 avatar Jun 01 '20 05:06 ajaykumar97

A neat and clean implementation:

import React, { PureComponent } from 'react'
import { Text, View, Dimensions } from 'react-native'
import { BorderShadow } from 'react-native-shadow';

const { width } = Dimensions.get('window');

export default class Example extends PureComponent {
  render() {
    const tabShadowOpt = {
      width,
      height: 80,
      color: 'black',
      border: 5,
      radius: 1,
      opacity: 0.6,
      x: 0,
      y: 5,
      style: {},
      side: 'top',
    };
    return (
      <View style={{ flex: 1, justifyContent: 'flex-end' }}>
        <BorderShadow setting={tabShadowOpt}>
          {[ //the main idea is to pass child in an array
            <View
              style={{
                width,
                height: 80,
                backgroundColor: 'black',
                alignItems: 'center',
                justifyContent: 'center'
              }}
            >
              <Text style={{ color: 'white' }}> textInComponent </Text>
            </View>
          ]}
        </BorderShadow>
      </View>
    )
  }
}

BorderShadow expects array of children instead of a single child. Hope this would help you.

Thanks! That's cool, do you know how to get rid of the warning saying each child shoud have a key?

changyu2hao avatar Jun 05 '20 14:06 changyu2hao