0

Foo is being displayed but not Bar. I am following a tutorial but using a different api but everything is the same, so I can't figure out why this isn't working.

import React, {Component} from 'react';
import ReactDOM from 'react-dom';

import movieDB from './themoviedb-javascript-library/themoviedb';

const movieList = () => {
return (
  <p>
  Bar
  </p>
);
}

class App extends Component {
constructor(props) {
super(props);
this.state = { movies: [] };

movieDB.search.getMovie({ "query":"Fight Club" }, (movies) => {
  // console.log(this)
  this.setState({movies: movies});
}, (err) => {
  console.log(err);
})
}

render() {
return (
  <div>
    Foo
    <movieList />
  </div>
)
}

}


ReactDOM.render(<App />, document.querySelector('.container'));
8
  • try it like this: {movieList} Commented Dec 28, 2017 at 23:30
  • @JosanIracheta I tried that with the same thinking but that also doesn't work. Commented Dec 28, 2017 at 23:31
  • 1
    how about {movieList()} Commented Dec 28, 2017 at 23:37
  • 1
    @David if you want to pass in props, your declaration for movieList would look something like const movieList = props => {....} Commented Dec 28, 2017 at 23:42
  • 1
    @David not necessarily. Components that look like const x = props => {...} are known as stateless components, and can also be used in the form of <x /> Commented Dec 28, 2017 at 23:47

1 Answer 1

2

React components have to be capitalized. MovieList should work. React treats lowercase tags as html tags and doesn't try to process them.

Sign up to request clarification or add additional context in comments.

1 Comment

This did it. Thank you!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.