Open ghost opened 7 years ago
Aha,
so then SeachResultsTracks.js would look like:
import React from 'react';
import './SearchResultTracks.css';
import { TrackList } from '../TrackList/TrackList';
export function SearchResultTracks(props) {
return (
<div className="SearchResults">
<h2>Results</h2>
<TrackList
addTrack={props.addTrack}
action='+'
tracks={props.searchResultTracks} />
</div>
);
}
Correct? It would still be a separate file in a seperate folder I guess?
The
class
syntax is the standard way to define a React component. But it's kind of a lot of ritual for a component that doesn't refer tothis.state
and only has arender()
function (like Tracklist or SearchResults) .In these situations, it's often preferable to write your component as a
stateless functional component
rather than a full blown component usingclass
.https://facebook.github.io/react/docs/components-and-props.html