0

I'm building an linked data application and having some trouble with my code which is as following

import React from 'react';
import URIUtil from '../../../utils/URIUtil';
class BasicIndividualView extends React.Component {
render() {
    let val, outputDIV;
    val = this.props.spec.value;
    if(this.props.spec.valueType === 'uri'){
        if(this.props.config){
            if(this.props.config.truncateURI){
                val = '<' + URIUtil.truncateMiddle(val, 50, '') + '>';
            }else if (this.props.config.shortenURI) {
                val = '<' + URIUtil.getURILabel(val) + '>';
            }
        }
        outputDIV = <a href={this.props.spec.value} target="_blank"> {val} </a>;
    }else{
        outputDIV = <span> {val} </span>;
    }
    return (
        <div className="ui" ref="basicIndividualView">
            {outputDIV}
        </div>
    );
  }
}

export default BasicIndividualView;

Now I want to display text, and if the text is a link I want to show the picture.

Joeri
  • 11
  • 3
  • Code looks fine. What's the output? You sure about the `if (this.props.spec.valueType === 'uri')` returns true? – Pavel Staselun Oct 26 '16 at 10:49
  • It is all working en there are no errors, The only thing is when de database query comes up with a link of a picture it remains a link where I want it to be the picture itself – Joeri Oct 26 '16 at 11:07
  • Ah, then it should look like `` – Pavel Staselun Oct 26 '16 at 11:27
  • Yeah it should work like that but the problem is the link comes up as plain text, so even with de src property there is no change. Thanks anyway for your quick answer! – Joeri Oct 26 '16 at 12:16

0 Answers0