software-mansion / radon-ide

VSCode extension that turns your editor into a fully fledged IDE for React Native and Expo.
https://ide.swmansion.com
Other
985 stars 33 forks source link

Problem with the Preview feature #533

Closed acouvreur1997 closed 2 months ago

acouvreur1997 commented 2 months ago

Description I want to try the Preview feature of react-native-ide with this sample file :

import * as React from "react"
import { Text, View } from "react-native"
import { preview } from "react-native-ide"

interface Props {
  title: string
}

const TestComponent = ({ title }: Props) => {
  return (
    <View style={{ backgroundColor: "red" }}>
      <Text style={{ color: "black" }}>{title}</Text>
    </View>
  )
}

preview(<TestComponent title="Test" />)

export default TestComponent

I have version 0.0.2 for "react-native-ide". But when i try to click on "Open preview" button above the preview(<TestComponent title="Test" />), i have a blank screen on the simulator and i have an error on the console :

Running "RNIDE_preview" with {"rootTag":21,"initialProps":{"previewKey":"preview://Users/Projets/ReactNativeIDE/Button.tsx:17"}} [React DevTools] Error calling listener Object TypeError: Cannot read property 'name' of undefined Cannot read property 'name' of undefined

I don't know what "name" he's talking about Have I done something wrong?

Environment

filip131311 commented 2 months ago

Hello, thank you so much for your feedback. Is the component in question imported anywhare into your bundle? I believe that it might be the issue. We are working on a solution for that problem, but for now, please import your component into some file that is used in the finale bundle and use preview function there.

I'll update you on future solutions in this thread.

acouvreur1997 commented 2 months ago

Hello Thank you for your answer. Indeed, if i import the component somewhere in my code, the preview feature works as expected :smile: