Our great sponsors
-
monorepo-example
Example of a simple Node Server and React app monorepo using git submodules (by alexeagleson)
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
lerna
:dragon: Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.
This is also a good time to commit your new project to your repository. I'll be doing that now as well, you can see the final version here.
import React from "react"; import logo from "./logo.svg"; import "./App.css"; import _ from "lodash"; import { QueryPayload } from "simple-express-server/server"; function App() { return (
Edit
src/App.tsxcode> and save to reload. p> {_.toUpper("Learn React")} a> { fetch("http://localhost:3001/", {}) .then((response) => response.json()) .then((data: QueryPayload) => console.log(data.payload)); }} > GET SOME DATA button> header> div> ); } export default App;
Let's say that there's a utility library that we want to use in both our React app and on our Express server. For simplicity let's choose lodash which many people are familiar with.
Lerna: For running scripts across multiple projects and adding new dependencies. Lerna is also built to manage publishing your packages (though we will not be doing that as part of this tutorial)
Related posts
- How ESLint Can Enforce Your Design System Best Practices
- Getting Started with Lodash: A Beginner's Guide to JavaScript Utility Functions
- JavaScript Equality Under the Lens: Enhancing React's Dependency Checks
- How to Remove Duplicate Objects from an Array in JavaScript
- Observables and Observers in RxJS