I'm trying to pass a variable into ReactVR via the URL.
When I console.log 'window.location.pathname' from within a component, it logs 'http://localhost:3001/dddfe37b-926a-4adf-b40c-fda47bf3cf8b',
even though my url is 'http://localhost:3001/vr", and the expected output is '/vr'.
I'd take any suggestions on how to pass a variable into ReactVR from an express.js route.
The code is boilerplate from react-vr init, with the exception of the "state", and "componentDidMount()"
import React from 'react';
import {
AppRegistry,
asset,
Pano,
Text,
View,
} from 'react-vr';
import io from 'socket.io-client';
export default class view_react_vr extends React.Component {
state = {
room: window.location.pathname
}
render() {
return (
<View>
<Pano source={asset('chess-world.jpg')}/>
<Text
style={{
backgroundColor: '#777879',
fontSize: 0.8,
fontWeight: '400',
layoutOrigin: [0.5, 0.5],
paddingLeft: 0.2,
paddingRight: 0.2,
textAlign: 'center',
textAlignVertical: 'center',
transform: [{translate: [0, 0, -3]}],
}}>
hello
</Text>
</View>
)
}
componentDidMount() {
let socket = io('http://localhost:3001/');
// socket.emit('newRoom', this.state.room);
socket.emit('updateState', this.state);
socket.on('updateState', nextState => {
console.log(nextState);
});
}
};
AppRegistry.registerComponent('view_react_vr', () => view_react_vr);