Personal development notes and experiments

Tagged “react”

Typescript - discriminated unions for more concise react component prop types

If your react component can accept a prop (or not) based on the value of another prop, typescript can help to avoid mistakes by giving proper warnings on incorrect usage.

2022-06-17

Access Express and CRA (Create React app) development server routes on same localhost port

Need to serve some static html's using Express for landing routes + serve a React app, and access this on one single local port for development? Don't use CRA's "proxy", instead use your Express backend to proxy requests to CRA dev server when needed.

2022-01-30

Make CRA dev server respond to CORS OPTIONS requests, as a gentleman should

Create React App allows you to configure a proxy server, modifying responses it makes. This can be useful for a lot of things, we'll use it to set up cross origin communication between two CRA apps running on same machine, different local domains.

2021-09-15