SHARE
TWEET

Untitled

a guest Jun 25th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class App extends Component {
  2.   constructor(props) {
  3.     super(props);
  4.     this.state = {
  5.       nodeResponse: ''
  6.   }
  7. }
  8.  
  9. getFileStatusFromNode = (data) => {
  10.     this.setState({nodeResponse: data})
  11.   }
  12.  
  13. render() {
  14.  
  15. let CardView = nodeResponse !== '' &&
  16.   <Card key={nodeResponse.fileName} name={nodeResponse.fileName} image={nodeResponse.buffer} />
  17.  
  18.  
  19. return (
  20.       <div className="App tc">
  21.          { CardView }
  22.       </div>
  23.      )
  24.    }
  25. }
  26.      
  27. class Card extends PureComponent {
  28.   constructor({props}) {
  29.     super(props);
  30.     this.state = {
  31.       src: '',
  32.     };
  33. }
  34.  
  35. componentDidMount() {
  36.   console.log("Card mounted")
  37.     this.setState(prevState => ({
  38.         src: [this.props.image, ...prevState.src]
  39.       }), () => console.log(this.state.src, this.props.name));
  40. }
  41.  
  42. render() {
  43.   const { name } = this.props;
  44.   const { src } = this.state;
  45.  
  46.  return (
  47.  
  48.       <a style={{width: 200, height: 250}} key={name} className={'tc'} >
  49.       <div id='images'>
  50.       <img style={{width: 175, height: 175}} className='tc' alt='missing' src={`data:image/jpeg;base64, ${src}`}/>
  51.       </div>
  52.       </a>
  53.     )
  54.   }
  55. }
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