12

** I have some issue when adding just Button !!**

and in the app that's the error

java.lang.string cannot be cast to com.facebook.react.uimanager.accessibility DelegateUtil$accessibilityRole

Error Button


my simple code

import React, { Component } from "react";
import { StyleSheet, TextInput, View, Button, Text } from "react-native";

export default class App extends Component {
  state = {
    placeName: ""
  };

  placeNameChangeHandler = val => {
    this.setState({
      placeName: val
    });
  };

  onPressLearnMore = () => {
    alert("Pressed");
  };

  render() {
    return (
      <View style={styles.container}>
        <Button
          onPress={this.onPressLearnMore}
          title="Learn More"
          color="#841584"    
        />

        <TextInput
          style={{
            width: 300,
            borderBottomWidth: 1,
            borderBottomColor: "#333"
          }}
          placeholder="Enter Name.."
          value={this.state.placeName}
          onChangeText={this.placeNameChangeHandler}
        />
      </View>
    );
  }
Ted
  • 14,757
  • 2
  • 41
  • 58
DevAS
  • 807
  • 2
  • 15
  • 41

2 Answers2

31

Yeah, it's a bug in react-native 0.57.3 but react-native 0.57.2 has its own issues!

So you have to downgrade to react-native 0.57.1 that is a bit more stable!

Do the following things in command prompt in the root directory of your project (these steps install some missed dependencies of this version):

1) delete your node_modules directory (command: rmdir node_modules /s in windows)

2) npm i -S react-native@0.57.1

3) npm add @babel/runtime

4) npm i -D schedule@0.4.0

5) npm i

now you can safely run react-native run-android or react-native run-ios.

hope this works for you (as it does for me).

Ali Radmanesh
  • 2,248
  • 22
  • 26
  • WTF! it's work Now :/ anyway thank u, bro, I have one Question, what's the right Command to init the new project without the last version? I do something like this ** react-native init myApp react-native@0.57.1**, but doesn't work and initial the last version 0.57.3! – DevAS Oct 13 '18 at 22:57
  • you should add [VERBOSE] such this: eeact-native init myApp react-native --version 0.57.1 – Ali Ghafoori Oct 14 '18 at 14:05
  • 1
    @Gha your welcome! if you want to create a new project with specific version (let's say 0.57.1) you can run `react-native init projectName --version@0.57.1`. – Ali Radmanesh Oct 14 '18 at 18:15
  • @AliRadmanesh thank u , i have some issue when i install react-navigation , i have bug " The development server returned response code:500 " what's this ? – DevAS Oct 14 '18 at 18:28
  • @Gha your question is not in the scope of this topic. You can ask another question in stackoverflow. But before that make sure to search the error you've got. good luck! – Ali Radmanesh Oct 14 '18 at 19:14
  • You sir, Ali Radmanesh, you are a lifesaver. Internet is useful because of good people like you <3 – Jithesh Kt Oct 15 '18 at 17:23
  • @JitheshKt Thank you. yeah, Internet and specially Stackoverflow is a lifesaver for developers :) – Ali Radmanesh Oct 17 '18 at 09:46
4

It's a bug in react-native version 0.57.3 so downgrading react-native version to 0.57.1 would be the workaround

Change the react-native version in package.json to explicitly be 0.57.1, not ^0.57.1

and delete node_modules folder

then do

npm i

Check here for updates regarding the issue

Hemadri Dasari
  • 32,666
  • 37
  • 119
  • 162