Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. class App extends React.Component {
  2. constructor(props) {
  3. super(props);
  4.  
  5. this.state = {
  6. activePanel: 'home',
  7. fetchedUser: null,
  8. token: null,
  9. video: null,
  10. grid: null,
  11. friends: null,
  12. };
  13. }
  14.  
  15.  
  16. componentDidMount() {
  17. connect.subscribe((e) => {
  18. switch (e.detail.type) {
  19. case 'VKWebAppAccessTokenReceived':
  20. this.setState({token :e.detail.data.access_token });
  21. connect.send("VKWebAppCallAPIMethod", {"method": "friends.get", "request_id": "32test", "params": {"fields": fields, "v":"5.101", "access_token": this.state.token}});
  22. break;
  23. case 'VKWebAppCallAPIMethodResult':
  24. this.setState({friends: e.detail.data.response.items})
  25. break;
  26. default:
  27. //что-то дефолтное
  28. }
  29. });
  30. connect.send("VKWebAppGetAuthToken", {"app_id": 7115545, "scope": "friends,status,video"});
  31. connect.send('VKWebAppGetUserInfo', {});
  32.  
  33. }
  34.  
  35. go = (e) => {
  36. this.setState({ activePanel: e.currentTarget.dataset.to })
  37. };
  38.  
  39. render() {
  40. return (
  41. <View >
  42. {this.state.friends !== null ? <div> {this.state.friends.map(el => <div> {el.photo_100} {el.bdate}</div>)}</div> : <div>nothing</div>}
  43. </View>
  44. );
  45. }
  46. }
  47.  
  48. export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement