title: useLeafletContext() can only be used in a descendant of <MapContainer>
body: <p>I am in the process of converting a leaflet-map in React into a hook with the use of react-leaflet and react-leaflet-markercluster. Everything worked perfectly except the use of the MarkerCluster component. The app gives this error:
  <code>Error: No context provided: useLeafletContext() can only be used in a descendant of &lt;MapContainer&gt;</code></p>
  <p>I have tried to do the exact same thing as in this codesandbox, including using the same versions of the packages:
  <a href="https://codesandbox.io/s/9binx?file=/src/styles.scss:168-206" rel="nofollow noreferrer">https://codesandbox.io/s/9binx?file=/src/styles.scss:168-206</a></p>
  <p>Both in the existing project and a completely fresh one (create-react-app). It still gives the same error in the existing project. So did the fresh project, but was fixed when removing this from the package.json:</p>
  <pre><code>    &quot;development&quot;: [
        &quot;last 1 chrome version&quot;,
        &quot;last 1 firefox version&quot;,
        &quot;last 1 safari version&quot;
      ]
  </code></pre>
  <p>This was never in the existing project though. Here is the package.json for the existing project:</p>
  <pre><code>{
      &quot;version&quot;: &quot;0.1.0&quot;,
      &quot;private&quot;: true,
      &quot;dependencies&quot;: {
          &quot;@reduxjs/toolkit&quot;: &quot;1.4.0&quot;,
          &quot;@sentry/react&quot;: &quot;5.27.1&quot;,
          &quot;@sentry/tracing&quot;: &quot;5.27.1&quot;,
          &quot;classnames&quot;: &quot;^2.3.1&quot;,
          &quot;http-proxy-middleware&quot;: &quot;1.0.6&quot;,
          &quot;leaflet&quot;: &quot;^1.7.1&quot;,
          &quot;leaflet.markercluster&quot;: &quot;^1.5.1&quot;,
          &quot;moment&quot;: &quot;2.29.1&quot;,
          &quot;normalize.css&quot;: &quot;8.0.1&quot;,
          &quot;rc-slider&quot;: &quot;9.5.4&quot;,
          &quot;react&quot;: &quot;17.0.1&quot;,
          &quot;react-app-polyfill&quot;: &quot;2.0.0&quot;,
          &quot;react-datepicker&quot;: &quot;3.3.0&quot;,
          &quot;react-dates&quot;: &quot;21.8.0&quot;,
          &quot;react-dom&quot;: &quot;17.0.1&quot;,
          &quot;react-html5-camera-photo&quot;: &quot;1.5.4&quot;,
          &quot;react-leaflet&quot;: &quot;^3.2.1&quot;,
          &quot;react-leaflet-markercluster&quot;: &quot;^3.0.0-rc1&quot;,
          &quot;react-markdown&quot;: &quot;5.0.2&quot;,
          &quot;react-query&quot;: &quot;2.25.2&quot;,
          &quot;react-redux&quot;: &quot;7.2.2&quot;,
          &quot;react-responsive-pinch-zoom-pan&quot;: &quot;0.3.0&quot;,
          &quot;react-router-dom&quot;: &quot;4.3.1&quot;,
          &quot;react-scripts&quot;: &quot;4.0.0&quot;,
          &quot;react-select&quot;: &quot;3.1.0&quot;,
          &quot;redux&quot;: &quot;4.0.5&quot;,
          &quot;redux-actions&quot;: &quot;2.6.5&quot;,
          &quot;redux-devtools-extension&quot;: &quot;2.13.8&quot;,
          &quot;redux-logger&quot;: &quot;3.0.6&quot;,
          &quot;redux-persist&quot;: &quot;6.0.0&quot;,
          &quot;redux-thunk&quot;: &quot;2.3.0&quot;,
          &quot;typescript&quot;: &quot;4.0.5&quot;
      },
      &quot;scripts&quot;: {
          &quot;start&quot;: &quot;BROWSER=NONE REACT_APP_DISABLE_LIVE_RELOAD=false react-scripts start&quot;,
          &quot;build&quot;: &quot;react-scripts build&quot;,
          &quot;build--withStats&quot;: &quot;react-scripts build --stats&quot;,
          &quot;test&quot;: &quot;react-scripts test&quot;,
          &quot;test:coverage&quot;: &quot;npm run test -- --coverage&quot;,
          &quot;eject&quot;: &quot;react-scripts eject&quot;,
          &quot;analyze&quot;: &quot;source-map-explorer build/static/js/main.*&quot;
      },
      &quot;lint-staged&quot;: {
          &quot;src/**/*.{js,jsx,ts,tsx,json,css}&quot;: [
              &quot;prettier --single-quote --tab-width 4 --write&quot;
          ]
      },
      &quot;husky&quot;: {
          &quot;hooks&quot;: {
              &quot;pre-commit&quot;: &quot;lint-staged&quot;
          }
      },
      &quot;eslintConfig&quot;: {
          &quot;extends&quot;: [
              &quot;react-app&quot;,
              &quot;react-app/jest&quot;
          ]
      },
      &quot;proxy&quot;: &quot;http://localhost:8080/&quot;,
      &quot;devDependencies&quot;: {
          &quot;@testing-library/dom&quot;: &quot;7.26.3&quot;,
          &quot;@testing-library/jest-dom&quot;: &quot;5.11.5&quot;,
          &quot;@testing-library/react&quot;: &quot;11.1.0&quot;,
          &quot;@testing-library/user-event&quot;: &quot;12.1.10&quot;,
          &quot;@tsconfig/recommended&quot;: &quot;1.0.1&quot;,
          &quot;@types/history&quot;: &quot;4.7.2&quot;,
          &quot;@types/jest&quot;: &quot;26.0.15&quot;,
          &quot;@types/leaflet&quot;: &quot;^1.5.19&quot;,
          &quot;@types/node&quot;: &quot;14.14.5&quot;,
          &quot;@types/react&quot;: &quot;16.9.53&quot;,
          &quot;@types/react-dom&quot;: &quot;16.9.8&quot;,
          &quot;@types/react-redux&quot;: &quot;7.1.9&quot;,
          &quot;@types/react-router-dom&quot;: &quot;4.3.1&quot;,
          &quot;@types/redux-logger&quot;: &quot;3.0.8&quot;,
          &quot;fetch-mock&quot;: &quot;^9.10.7&quot;,
          &quot;fetch-mock-jest&quot;: &quot;^1.3.0&quot;,
          &quot;husky&quot;: &quot;4.3.0&quot;,
          &quot;jest-environment-jsdom-sixteen&quot;: &quot;1.0.3&quot;,
          &quot;lint-staged&quot;: &quot;10.5.0&quot;,
          &quot;msw&quot;: &quot;0.21.3&quot;,
          &quot;prettier&quot;: &quot;2.1.2&quot;,
          &quot;source-map-explorer&quot;: &quot;2.5.0&quot;
      },
      &quot;browserslist&quot;: [
          &quot;&gt;0.2%&quot;,
          &quot;not dead&quot;,
          &quot;not op_mini all&quot;
      ],
      &quot;jest&quot;: {
          &quot;collectCoverageFrom&quot;: [
              &quot;src/**/*.{js,jsx,ts,tsx}&quot;,
              &quot;!&lt;rootDir&gt;/node_modules/&quot;,
              &quot;!&lt;rootDir&gt;/integration-tests/&quot;,
              &quot;!&lt;rootDir&gt;/public/&quot;,
              &quot;!&lt;rootDir&gt;/build/&quot;
          ],
          &quot;coverageThreshold&quot;: {
              &quot;global&quot;: {
                  &quot;branches&quot;: 90,
                  &quot;functions&quot;: 90,
                  &quot;lines&quot;: 90,
                  &quot;statements&quot;: 90
              }
          },
          &quot;coverageReporters&quot;: [
              &quot;text&quot;
          ]
      }
  }
  </code></pre>
  <p>Anyone have any clue as to what it could be that's causing the error?</p>