Combine react-native component with vue-native
Asked Answered
O

1

6

Is there any way I could combine react native component like this one https://github.com/archriss/react-native-snap-carousel/tree/master/example with a vue native?

I have a project in vue-native and want to use react-native component inside it, but I have an erro I do not understand: The console says: Invariant Violation: expected a string (for built-in components) or a class/function (for composite components) but got: undefined

<template>
  <nb-container>
    <nb-content>
              <carousel
                :data="similarEventsData"
                :renderItem="_renderItem"
                :sliderWidth="sliderWidth"
                :itemWidth="itemWidth"
                :inactiveSlideScale="0.95"
                :inactiveSlideOpacity="1"
                :enableMomentum="true"
                :activeSlideAlignment="'start'"
                :containerCustomStyle="stylesObj.slider"
                :contentContainerCustomStyle="stylesObj.sliderContentContainer"
                :activeAnimationType="'spring'"
                :activeAnimationOptions="{ friction: 4, tension: 40 }"
              />
    </nb-content>
  </nb-container>
</template>

<script>
import { Dimensions, Platform, Share } from "react-native";
import Carousel from 'react-native-snap-carousel';
import { scrollInterpolators, animatedStyles } from '../../utils/animations';

const { width: viewportWidth, height: viewportHeight } = Dimensions.get('window');
const slideHeight = viewportHeight * 0.36;
const slideWidth = wp(75);
const itemHorizontalMargin = wp(2);

export default {
  components: { carousel: Carousel },
  computed: {
    similarEventsData () {
      return [1, 2, 3]
    }
  },
  data: function() {
    return {
      sliderWidth: viewportWidth,
      itemWidth: slideWidth + itemHorizontalMargin * 2,
      stylesObj: {
        slider: {
          marginTop: 15,
          overflow: 'visible'
        },
        sliderContentContainer: {
          paddingVertical: 10
        },
      }
    };
  },
  methods: {
    _renderItem ({item, index}) {
      return <Text>fsd</Text>;
    },
  },
};
</script>

I expect to render a component but with no luck

Orissa answered 7/4, 2019 at 22:50 Comment(1)
Did you find a solution?Theorbo
H
0

this question is about 2 years old and I think in that time the devs added the functionality to do so, if somehow anyone is experiencing this question and ran into this post, here's what to do:

Example with Entypo icon pack from expo vector icons:

<script>
import { Entypo } from '@expo/vector-icons'; 

export default {
  data(){
    components: { Entype }
 }
}
</script>

and then in template:

<template>
<entypo />
</template>
Hubbs answered 20/12, 2021 at 17:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.