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

BorderShadow #31

Open
williamdwarke opened this issue Apr 19, 2018 · 7 comments
Open

BorderShadow #31

williamdwarke opened this issue Apr 19, 2018 · 7 comments

Comments

@williamdwarke
Copy link

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.

@muhammadasjadamin
Copy link

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.. "

@ajaykumar97
Copy link

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.

@ethaqnix
Copy link

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

@CyxouD
Copy link

CyxouD commented Oct 18, 2019

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

@changyu2hao
Copy link

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?

@ajaykumar97
Copy link

ajaykumar97 commented Jun 1, 2020

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.

@changyu2hao
Copy link

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?

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

6 participants