I am trying to build a web app with python, HTML, Javascript, React, Flask. I created python package and my HTML can find the javascript. But it was not replacing the item in the HTML. I would really appreciate it if anyone has any insight.
I have installed react chrome tool but it says that that page is not using react. So I really don't know how to debug this error anymore. If anyone has insights on this please comment as well.
tree:
├── README.md
├── bin
│ ├── install
│ └── run
└── meme
├── meme
│ ├── __init__.py
│ ├── main.py
│ ├── static
│ │ └── js
│ │ ├── generate.jsx
│ │ └── search.jsx
│ └── templates
│ ├── generate.html
│ └── search.html
├── meme.egg-info
│ ├── PKG-INFO
│ ├── SOURCES.txt
│ ├── dependency_links.txt
│ ├── requires.txt
│ └── top_level.txt
└── setup.py
What localhost:8888/search/ looks like: Apparently it is not rendering.
Loading...
search.HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Search</title>
</head>
<body>
<div id="reactEntry">Loading...</div>
<script type="text/javascript" src="{{url_for('static', filename="js/search.jsx")}}"></script>
</body>
</html>
search.jsx:
import React from 'react';
import ReactDOM from 'react-dom';
class SearchObj extends React.Component {
constructor(props) {
super(props)
this.state = {
query = "",
imgs = [{"name": "img1"}, {"name": "img2"}], // list of img dictionary
}
this.submitQuery = this.submitQuery.bind(this);
}
submitQuery() {}
render() {
console.log("render")
return (
<form onSubmit={this.submitQuery}>
<input id="query" type="text" name="submit">submit query</input>
</form>
);
}
}
// This method is only called once
ReactDOM.render(
<SearchObj url="/search/" />,
document.getElementById('reactEntry'),
);