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

TypeError: Cannot set property userAgent of #<Navigator> which has only a getter #62

Open
apanchati opened this issue Dec 17, 2020 · 1 comment

Comments

@apanchati
Copy link

Hi,
I am getting "TypeError: Cannot set property userAgent of # which has only a getter" on line 15 of index.js file.

Below line is from the \node_modules\react-native-signalr\src\index.js file where i am getting the error.
window.navigator.userAgent = window.navigator.userAgent || "react-native";

I am trying to create an android app using expo. I get this error when testing in the browser.
Below is code from my App.js file:

`
import React from "react"
import { StyleSheet, View, Text } from "react-native"
import signalr from "react-native-signalr"

let isConnected = "no"

export default class App extends React.Component {

async componentDidMount() {
	try {
		const connection = signalr.hubConnection("replace with signalr URL")
		connection.logging = true

		connection.start().done(function () {
			isConnected = "connected"
		})

		connection.error((error) => {
			const errorMessage = error.message;
			let detailedError = "";
			if (error.source && error.source._response) {
			  detailedError = error.source._response;
			}
			if (detailedError === "An SSL error has occurred and a secure connection to the server cannot be made.") {
			  console.log("When using react-native-signalr on ios with http remember to enable http in App Transport Security https://github.com/olofd/react-native-signalr/issues/14")
			}
			console.debug("SignalR error: " + errorMessage, detailedError)
		  });
	} catch (e) {
		console.log(e)
	}
}


render() {
	return (
		<View style={styles.container}>
			<Text style={[styles.trackInfoText, styles.largeText]}>
				SignalR status: {isConnected}
			</Text>
		</View>
	)
}

}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
},
albumCover: {
width: 250,
height: 250
},
trackInfo: {
padding: 40,
backgroundColor: "#fff"
},

trackInfoText: {
	textAlign: "center",
	flexWrap: "wrap",
	color: "#550088"
},
largeText: {
	fontSize: 22
},
smallText: {
	fontSize: 16
},
control: {
	margin: 20
},
controls: {
	flexDirection: "row"
}

})

`

Thanks,
Ahmed

@uffe
Copy link

uffe commented Feb 16, 2023

Did you ever find a solution to this issue @apanchati ?
I am seeing a similar issue using react-native-web

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

2 participants