Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 6th, 2020 186 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { useState, useEffect } from 'react';
  2. import { fetchMessages } from './services';
  3. import errorMessages from './errorMessages';
  4.  
  5. const RefreshMessages = ({ user }) => {
  6.     // This state is all local to the component
  7.     const [error, setError] = useState('');
  8.     const [currentMessages, setCurrentMessages] = useState([]);
  9.  
  10.     useEffect(() => {
  11.         //setInterval(() => {
  12.         console.log('call to refresh messages:');
  13.         console.log(user);
  14.         setError('');
  15.         // start service call
  16.         fetchMessages()
  17.             .then((messages) => {
  18.                 setCurrentMessages(messages);
  19.                 console.log("Refresh messages");
  20.                 console.log(messages);
  21.                 // onMessage(true, messages);
  22.             })
  23.             .catch((err) => {
  24.                 setError(errorMessages[err.code || 'DEFAULT']);
  25.                 if (err.code === errorMessages.USER_NOTFOUND || err.code === errorMessages.USER_UNAUTHORIZED) {
  26.                     //onMessage(false, []);
  27.                 }
  28.             });
  29.         //}, 500);
  30.     }, []);
  31.  
  32.     return (
  33.         <div className="CurrentMessages">
  34.             <p className="error">{error}</p>
  35.             <h2>Messages:</h2>
  36.             <ul className="Messages">
  37.  
  38.                 {currentMessages.map(message =>
  39.                     <p><b>User:</b> {message.username}, <b>Message:</b> {message.text}, <b>Time:</b> {message.timestamp}</p>
  40.                 )}
  41.             </ul>
  42.         </div >
  43.     );
  44. };
  45.  
  46. export default RefreshMessages;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top