zcreativelabs / react-simple-maps

Beautiful React SVG maps with d3-geo and topojson using a declarative api.
https://www.react-simple-maps.io/
MIT License
3.12k stars 426 forks source link

prop-types dependencies #301

Open TripleJBlog opened 2 years ago

TripleJBlog commented 2 years ago

This library requires prop-types dependency extracted from the built-in React v15.5.0.

Please include prop-types in project or remove the dependency so that users don't have to find dependencies.

dezyh commented 1 year ago

I'm still having this issue with a clean install of vite and react-simple-maps. After installing prop-types, the below error was resolved.

✘ [ERROR] Could not resolve "prop-types"

    node_modules/react-simple-maps/dist/index.es.js:2:22:
      2 │ import PropTypes from 'prop-types';
        ╵                       ~~~~~~~~~~~~

  You can mark the path "prop-types" as external to exclude it from the bundle, which will remove
  this error.

Reproduction

  1. Create a react project with vite:
    yarn create vite missing-dependency-example --template react-swc-ts && \
    cd missing-dependency-example && \
    yarn add react-simple-maps@3.0.0 && \
    yarn add @types/react-simple-maps && \
    yarn install
  2. Replace App.tsx with the (slightly modified) example:
    
    import React from 'react';

import { ComposableMap, Geographies, Geography } from 'react-simple-maps';

const geoUrl = "https://raw.githubusercontent.com/deldersveld/topojson/master/world-countries.json";

const MapChart = () => { return (

{({ geographies }) => geographies.map((geo) => ( )) }

) }

const App = () => { return (

) } export default App; ```` 3. Run to see error ```` yarn run dev ````