import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
import Icon from './components/Icon';
import Discover from './components/Discover';
import Post from './components/Post';
import Thread from './components/Thread';
import LoginButton from './components/LoginButton';
import Footer from './components/Footer';
class App extends React.Component {
constructor(props) {
super(props);
this.auth = this.auth.bind(this);
this.state = {
visitor: { uid: 0 }
};
this.auth(window.localStorage.hash || '')
}
render() {
return (
)
}
auth(data) {
if (data) {
window.localStorage.hash = data;
fetch(`https://api.juick.com/users?hash=${data}`)
.then(response => {
return response.json()
})
.then(users => {
let visitor = users[0]
visitor.hash = data
this.setState({
visitor: visitor
})
})
}
}
}
ReactDOM.render(, document.getElementById('wrapper'));