FIRST, I need to know how to import a Web Resoruce (html with react.js) WITHOUT USING NODE.JS! then... I want to create a solution with a Web Resource (an html file with react.js) with multiple scripts linked to it, I have no Idea how to do it, ¿can someone give me a simple example? I CAN'T USE NODE.JS or any other thing, just the html with react, and I need to put the scripts files in it.
This is my code (doesn't work):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="icon" type="image/png" href="src/reactFavicon.png">
<link href="">fonts.googleapis.com/css rel="stylesheet">
<title>Users</title>
</head>
<body>
<div id="root"></div>
<script type="text/javascript" src="users.js">
</body>
</html>
--------------------------------------------------------------------------------------------------------------------
This is the users.js script:
const rootElement = document.getElementById('root')
class Users extends React.Component {
constructor(props) {
super(props)
this.state = {
items:[],
isLoaded: false
}
}
componentDidMount() {
.then(res => res.json())
.then(json => {
this.setState({
isLoaded: true,
items: json
})
})
}
render() {
const title = this.props.title;
var {isLoaded, items} = this.state;
if(!isLoaded) {
return <div>Loading...</div>
} else {
return(
<div class="Users">
{title}
<ul>
{items.map(item => (
<li key={item.id}>
{item.name} | {item.email} ||| lives in {item.address.street}, {item.address.suite} ({item.address.city}), his/her phone number is {item.phone} and works in <strong>{item.company.name}</strong>.
</li>
)) }
</ul>
</div>
)
}
}
}
function App() {
return (
<div>
<Users
title = "Users"
/>
</div>
)
}
ReactDOM.render(
<App />,
rootElement
)
--------------------------------------------------------------------------------------------------------------------
If someone can really help me with this, I'll be really thankful (the code is just an example, it can be any other thing you want, just keep it simple).