better api template & css modules example

This commit is contained in:
Ben Elferink
2020-12-27 01:43:04 +02:00
parent 40e22e0392
commit cb078bf083
4 changed files with 25 additions and 20 deletions

View File

@@ -1,21 +1,23 @@
import React from 'react';
import HelloWorld from './components/HelloWorld';
import './style/style.css';
import './style/style.css'; // regular CSS -> className='app'
import styles from './style/App.module.css'; // module CSS -> className={styles.App} (AKA styled components)
// import * as api from './api';
// un-comment this ^ ^ ^ to import api endpoints
// ^ ^ ^ un-comment this to import api endpoints
function App() {
// const [data, setData] = React.useState([]);
// React.useEffect(() => {
// api
// .getSomething() // replace this with your endpoint
// .then((response) => console.log(`✅ ${response.status} ${response.statusText}`, response.data))
// .then((response) => console.log(`✅ ${response.status} ${response.statusText}`, setData(response.data)))
// .catch((error) => console.log(`❌ ${error}`));
// });
// }, []);
//
// example ^ ^ ^ using the api endpoint
// ^ ^ ^ example using the api endpoint
return (
<div className='App'>
<div className={styles.App}>
<HelloWorld />
</div>
);