I’ve been following along with the Learning React (2nd Edition) book for a few weeks now, and I’ve encountered an error at chapter 15 where I’m building a todo list.
The relevant code is:
index.html:
<!doctype html>
<html lang="en">
<head>
<title>Todo List</title>
</head>
<body>
<div id="#container">
</div>
</body>
</html>
index.js:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import TodoList from './TodoList';
var destination = document.querySelector("#container");
ReactDOM.render(
<div>
<TodoList/>
</div>,
destination
);
TodoList.js
import React, { Component } from "react";
class TodoList extends Component{
render(){
return (
<div className="todoListMain">
<div className="header">
<form>
<input placeholder="enter task">
</input>
<button type="submit">add</button>
</form>
</div>
</div>
);
}
}
export default TodoList;
And then the error I’m getting:
I did some searching and the only useful thing I found was that the thing in the render (<TodoList/>) might not be a valid component, but since it is properly extending Component I don’t have any reason to believe that’s the case.
I’ve been stumped on this for a couple days, so I’d appreciate any help!
Edit: I just tried the using the code from https://github.com/kirupa/kirupa/blob/master/reactjs/todolist/ and I’m getting the same error, so it looks like something is wrong with the book’s implementation.