observablehq / examples

Examples of using Observable in a variety of contexts
106 stars 33 forks source link

Add React Dataflow example using dynamic import #22

Closed tophtucker closed 1 year ago

tophtucker commented 2 years ago

A user asked Cobus if you could embed a notebook in React such that it fetches the latest published version of the notebook at runtime, instead of installing and checking in and bundling and having to redeploy if you make changes.

This also sidesteps the file attachment bundler issues! Wondering if it should be the default technique we recommend in the Embed modal.

tophtucker commented 2 years ago

behavior is identical to https://observablehq.github.io/examples/react-dataflow/

(oops gotta update the styles in my new one)

tophtucker commented 2 years ago

oh i could also strip out the create-react-app junk and use rollup or…

CobusT commented 2 years ago

Wondering if it should be the default technique we recommend in the Embed modal.

How about we call the existing method "Runtime with React (downloaded)" and add another type called "Runtime with React (dynamic)"?

tophtucker commented 2 years ago

(gotta switch to some other work, will come back to this maybe tonight & rip out create-react-app so it's not 12k lines of package-lock lol)

tophtucker commented 2 years ago

Previous create-react-app version of the PR: +11,923 lines of code

Now just adapting the rollup config from react-dataflow example: +1,039 lines of code 😅