Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use "react-create-react-app" with other D3 template? #18

Open
metascience-lab opened this issue Oct 25, 2021 · 1 comment
Open

Comments

@metascience-lab
Copy link

Hi Tophtucker,
Thanks for your example code! As a beginner, I have one question.

I wish to use one of your example "react-create-react-app" with other D3 template, so I downloaded the source code of the new template and put it in scr/@d3/NewTemplate. Also, I run:
yarn add @observablehq/runtime, then I have the new file in ./file to build my fileAttachments variable in json script.
But when I used the original file downloaded by yarn add @observablehq/runtime, the webpage could not show out successfully. I noticed that you mentioned in the ReadMe file in "react-create-react-app" that we need to replace this file name with flare.json. I am confused about which .json file is suitable for the new template? I tried flare.json but it doesn't work. Could you pls give me a hand? Thank you so much!

@heaversm
Copy link

The fix for me was to:

run the yarn commands that it tells you to in the embed options of observable, for example:

yarn add @observablehq/runtime@4
yarn add "https://api.observablehq.com/@heaversm/mozilla-ecosystem.tgz?v=3"

copy the json file from the node_modules/[your_directory]/files directory into create react app's /public directory, give it an extension of .json (it has no extension by default), and then edit the javascript in the node_modules/[your_directory]/[your_file].js file so that the import is, for example:

new Map([["[email protected]","/files/af12b2c45618d5de452c00b06fedb7419a7733e49ba65d051f45b3f9c754b41b842343db07d77422daa2137734c5eb09737342b5a5dda9ca509055fcd8f9a758.json"]]);

instead of:

new Map([["[email protected]",new URL("./files/af12b2c45618d5de452c00b06fedb7419a7733e49ba65d051f45b3f9c754b41b842343db07d77422daa2137734c5eb09737342b5a5dda9ca509055fcd8f9a758",import.meta.url)]]);

then re-run yarn start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants