Uncaught TypeError: Cannot read property 'getAll' of null

See original GitHub issue

mapbox-gl-js version: mapbox-gl-draw version:

Steps to Trigger Behavior

  1. Get control instance
  2. Add control to the map
  3. Remove control
  4. Add control again
  5. Call getAll() method of control

This is because of assign null to ctx.store

https://github.com/mapbox/mapbox-gl-draw/blob/c7ff98dfc92aa2befb46bb212e7b59ce7bb89820/src/setup.js#L25

      const control = new MapboxDraw({
        displayControlsDefault: false,
        controls: {
          polygon: true,
          trash: true
        },
        userProperties: true,
        styles: drawStyles
      });

      mapInstance.addControl(control);
      mapInstance.removeControl(control);
      mapInstance.addControl(control);

      const { features } = control.getAll();

      // Features array
      console.log('features: ', features);

Expected Behavior

Features array

Actual Behavior

     
      zone-evergreen.js:172 Uncaught TypeError: Cannot read property 'getAll' of null
    at push../node_modules/@mapbox/mapbox-gl-draw/index.js.module.exports.api.getAll (api.js:121)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

4reactions
sdymj84commented, Sep 8, 2021

Any solution on this?

0reactions
wtravOcommented, Jul 12, 2022

Bump. Anyone found a solution for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Native-Contacts: Cannot read property 'getAll' of null
I get this error. TypeError: Cannot read property 'getAll' of null. For some reason importing Contacts from react-native-contacts appears to be ...
Read more >
Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError : Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an...
Read more >
lightning - Cannot Read Property 'getList' of Null Exception
I have a component which iterates over a list of records and in turn calls a child component for each record returned. This...
Read more >
uncaught typeerror: cannot read properties of null ... - You.com
1 The error says that jsonObject is null. You are testing if data is null. Therefore data must null expressed as JSON so...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found