react-simple-maps icon indicating copy to clipboard operation
react-simple-maps copied to clipboard

prop-types dependencies

Open TripleJBlog opened this issue 3 years ago • 1 comments

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.

TripleJBlog avatar Sep 25 '22 23:09 TripleJBlog

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 [email protected] && \
yarn add @types/react-simple-maps && \
yarn install
  1. 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 (
    <ComposableMap>
      <Geographies geography={geoUrl}>
        {({ geographies }) =>
          geographies.map((geo) => (
            <Geography key={geo.rsmKey} geography={geo} />
          ))
        }
      </Geographies>
    </ComposableMap>
  )
}

const App = () => {
  return (
    <React.Fragment>
      <MapChart />
    </React.Fragment>
  )
}

export default App;
  1. Run to see error
yarn run dev

dezyh avatar Jan 06 '23 17:01 dezyh