codeforboston / codeforboston/mattapan-mapping
Move boundaries and assets folder into public
- Dominant language
- TypeScript
- Stars
- 5
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
Create React App (CRA) doesn't allow to import files or modules from outside of `/src`; however there is an 'escape hatch' that allows for data files / assets to be called from the `/public` folder https://create-react-app.dev/docs/using-the-public-folder/
The files in `/boundaries` are currently normal .js files, none of which have an exported member (so it isn't realistically possible to import them anyway)
CRA doesn't explicitly recommend to have json/geojson/data-like files in public folder, but this might be the easiest solution given the already existing boundary data and also for some way for GitHub hooks to continually update data as it is pulled
https://create-react-app.dev/docs/using-the-public-folder/#when-to-use-the-public-folder
A suggested (albeit heavy-handed) approach:
* These js files should be converted in to .json or .geojson files (remove the var declarations in each of the boundary files and update the filename to .json or .geojson - if .geojson must be valid geojson https://geojsonlint.com)
* Move these .json/.geojson in `/public/boundaries` so that GitHub actions can keep pointing to this folder and do its update data thing;
* Create a custom hook that actually `fetch`es the json/geojson from the public folder so the app can tangibly use the data. Recommended to be able to pass in the file location as an argument to the hook
* https://reactjs.org/docs/hooks-custom.html
* https://stackoverflow.com/questions/46793310/fetch-local-json-file-from-public-folder-reactjs
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.