Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class App extends Component {
- constructor(props) {
- super(props);
- this.state = {
- nodeResponse: ''
- }
- }
- getFileStatusFromNode = (data) => {
- this.setState({nodeResponse: data})
- }
- render() {
- let CardView = nodeResponse !== '' &&
- <Card key={nodeResponse.fileName} name={nodeResponse.fileName} image={nodeResponse.buffer} />
- return (
- <div className="App tc">
- { CardView }
- </div>
- )
- }
- }
- class Card extends PureComponent {
- constructor({props}) {
- super(props);
- this.state = {
- src: '',
- };
- }
- componentDidMount() {
- console.log("Card mounted")
- this.setState(prevState => ({
- src: [this.props.image, ...prevState.src]
- }), () => console.log(this.state.src, this.props.name));
- }
- render() {
- const { name } = this.props;
- const { src } = this.state;
- return (
- <a style={{width: 200, height: 250}} key={name} className={'tc'} >
- <div id='images'>
- <img style={{width: 175, height: 175}} className='tc' alt='missing' src={`data:image/jpeg;base64, ${src}`}/>
- </div>
- </a>
- )
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement