At the moment I can create react apps, get content from APIs and all that good stuff. Recently I say a tutorial where react is rendered through express:
const app = express();
app.use(express.static(“public”));
app.get('*', (req,res)=>{
res.send(`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="/bundle.js" defer></script>
</head>
<body>
<div id="root">${renderToString(<App />)}</div>
</body>
</html>`);
})
Is this the approach professionals take or do they just create react apps (kind of starting with create-react-app
) and just reaching for an API,
What I’m trying to figure out is, I am going to learn how this works just to say I played with it, but is this the approach I should use every time I create react apps?