<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: bellancaf</title>
    <description>The latest articles on DEV Community by bellancaf (@bellancaf).</description>
    <link>https://dev.to/bellancaf</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F194014%2F8e3ce748-a565-4042-ad69-a9329b36e0b8.jpeg</url>
      <title>DEV Community: bellancaf</title>
      <link>https://dev.to/bellancaf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bellancaf"/>
    <language>en</language>
    <item>
      <title>Expected a string (for built-in components) or a class/function (for composite components) but got: undefined</title>
      <dc:creator>bellancaf</dc:creator>
      <pubDate>Thu, 11 Jul 2019 22:48:26 +0000</pubDate>
      <link>https://dev.to/bellancaf/expected-a-string-for-built-in-components-or-a-class-function-for-composite-components-but-got-undefined-355d</link>
      <guid>https://dev.to/bellancaf/expected-a-string-for-built-in-components-or-a-class-function-for-composite-components-but-got-undefined-355d</guid>
      <description>&lt;p&gt;Hellow Everyone! &lt;/p&gt;

&lt;p&gt;I am experiencing a small (big) annoying issue :D &lt;/p&gt;

&lt;p&gt;The system on our marketplace is not able to fetch certain products but successfully manages to get others. &lt;/p&gt;

&lt;p&gt;-&amp;gt; &lt;a href="https://www.feralhorses.co.uk/artworks/i-belong-to-you"&gt;https://www.feralhorses.co.uk/artworks/i-belong-to-you&lt;/a&gt; (works) &lt;br&gt;
-&amp;gt; &lt;a href="https://www.feralhorses.co.uk/artworks/parallel-expressions"&gt;https://www.feralhorses.co.uk/artworks/parallel-expressions&lt;/a&gt; (doesn't work)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as authActions from '../actions/authActions';
import * as lotActions from '../actions/lotActions';
import { requestCurrentLot } from '../utils/crudHelpers';
import { logActions, createLog } from '../utils/logHelpers';
import { checkToken } from '../utils/authHelpers';
import SingleArtworkPrimary from './SingleArtworkPrimary';
import SingleArtworkSecondary from './SingleArtworkSecondary';
import {
  requestArtworkByName,
  requestSingleArtworkGeneral,
  requestArtworks
} from '../utils/crudHelpers';

class SingleArtworkContainer extends Component {
  constructor(props) {
    super(props);

    this.getSingleArtwork = this.getSingleArtwork.bind(this);    
    this.requestArtistPrimaryArtworks = this.requestArtistPrimaryArtworks.bind(this);
    this.readUrl = this.readUrl.bind(this);

    this.state = {
      singleArtwork: null,
      artistArtworks: []      
    };
  }

  componentDidMount() {
    if (checkToken()) {
      document.body.classList.add('is-auth');
    }
    this.getSingleArtwork(this.readUrl());  
  }

  readUrl() {
    const browserPath = window.location.pathname;
    return browserPath.split('/')[2];
  }

  getSingleArtwork(artworkTitle) {
    requestSingleArtworkGeneral(artworkTitle)
      .then((response) =&amp;gt; {
        if(response.data.result){
          const { artwork } = response.data;
          if (artwork.status === 2) {
            this.requestArtistPrimaryArtworks(artwork.primary_lot_id, artwork.artist.pretty_url);
          }
          this.setState({
            singleArtwork: artwork
          });
          if(checkToken()) {
            createLog(logActions.primaryMarketArtwork, `Artwork: ${artwork.artwork_id}-${artwork.artwork_title} by ${artwork.artist_name}`);
          }
        } else {
          authActions.forwardUserTo('/not-found');
        }
      })
      .catch((err) =&amp;gt; {
        console.log(err);
      });
  }

  requestArtistPrimaryArtworks(lot_id, prettyUrl) {
    requestArtworks(1, lot_id, 3, {artist_pretty_url: prettyUrl})
      .then((response) =&amp;gt; {
        response.data.primary_lot_artworks.map((artwork, key) =&amp;gt; {
          this.state.artistArtworks.push(artwork);
        });
        this.setState({
          isLoading: false          
        });
      })
      .catch((err) =&amp;gt; {
        console.log(err);
      });
  }

  render() {
    if(this.state.singleArtwork === null) {
      return (
        &amp;lt;div style={{ minHeight: '95vh' }}&amp;gt;
          &amp;lt;h3&amp;gt;Loading&amp;lt;/h3&amp;gt;
        &amp;lt;/div&amp;gt;
      );
    } else if (this.state.singleArtwork.status === 2) {
      return (
        &amp;lt;div&amp;gt;
          &amp;lt;SingleArtworkPrimary
            artwork={this.state.singleArtwork}
            artistArtworks={this.state.artistArtworks}
            /&amp;gt;
        &amp;lt;/div&amp;gt;
      );
    } else {
      return (
        &amp;lt;div&amp;gt;
          &amp;lt;SingleArtworkSecondary 
            artwork={this.state.singleArtwork}
            /&amp;gt;
        &amp;lt;/div&amp;gt;
      );
    }
  }
}

const mapStateToProps = (state, ownProps) =&amp;gt; ({
  lot: state.lots.lot
});

const mapDispatchToProps = (dispatch) =&amp;gt; ({
  actions: {
    lotActions: bindActionCreators(lotActions, dispatch)
  }
});

SingleArtworkContainer.propTypes = {
  artwork: PropTypes.object,
  from: PropTypes.string,
  lot: PropTypes.object
};

export default connect(mapStateToProps, mapDispatchToProps)(SingleArtworkContainer);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;My first catch error is what consoles it out&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the expected behavior?&lt;/strong&gt;&lt;br&gt;
Given that this is exactly the same code I am honestly surprised by the fact that I get a React error as the code behind the two pages is literally the same :(  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?&lt;/strong&gt;&lt;br&gt;
All browsers &lt;br&gt;
React 15.3.0 (but also happens in our UAT machine with react 16.8) &lt;/p&gt;

</description>
      <category>react</category>
    </item>
  </channel>
</rss>
