How I got where I am(you can skip to next paragraph)
Recently I picked up react-native for mobile development and it was hell, spent 3 hours googling solutions why isn't my react-native init
project even run, after downgrading a couple of packages I was able to run this blank app fine, but soon after, I was still receiving errors that didn't seem to be even from my code.. So 3 days into development and chill where I have seen nothing more, but various errors and I didn't progress with the app at all.
My latest issue I can't solve for quite some time:
So the error I am getting is "Attempted to assign to readonly property". Now the stack trace always points to node_modules/../ReactNativeRenderer-dev.js
this is my code that has almost nothing in it and still reproduces the issue
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Button} from 'react-native';
import { createStackNavigator} from 'react-navigation';
// routes
//import HeaderComp from './src/components/headerComp';
//import NavigatorDiv from './src/router';
class Home extends React.Component{
render() {
return <Text> hello this is home </Text>
}
}
class List extends React.Component{
render() {
return <Text> hello this is List </Text>
}
}
const NavigatorDiv = createStackNavigator({
Home: {
screen: Home
},
MusicListView: {
screen: List
},
}, {
initialRouteName: 'Home',
});
type Props = {};
export default class App extends React.Component<Props> {
render() {
return <NavigatorDiv/>
}
}
EDIT So it appears that the only way to fix something in react-native is to downgrade it even more, I started with 0.56, maybe by the end of this week I will reach the first alpha, anyways, the error is fixed, the code runs fine with this setup: react-native-cli: 2.0.1 react-native: 0.50.0
type Props = {};
that looks suspicious, is that using typescript? - also, since you haveimport { Component } from 'react'
you dont need to doclass extends React.Component
you can just doclass extends Component
- Abdul Ahmad