Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated 3.0.5 and MapLayer is not exported from 'react-leaflet' (it was 1.7.0) #818

Closed
umitduran opened this issue Dec 28, 2020 · 3 comments

Comments

@umitduran
Copy link

umitduran commented Dec 28, 2020

MapLayer Not Found

Hi,

I updated the my react-leaflet library from 1.7.0 to 3.0.5

In my project i am using HeatMapLayer extends from MapLayer. After updating i am getting this error 'Attempted import error: 'MapLayer' is not exported from 'react-leaflet'.
Below my code block here
export default class HeatMapLayer extends MapLayer { createLeafletElement() { return null; } componentDidMount() {} ... }
What should i do ?

@silviuburceadev
Copy link

3.x is a breaking change, no MapLayer anymore.

@umitduran
Copy link
Author

3.x is a breaking change, no MapLayer anymore.

Instead of the MapLayer what i should use ? Do you have any idea ?

@anajavi
Copy link
Contributor

anajavi commented Jan 14, 2021

3.x is a breaking change, no MapLayer anymore.

Instead of the MapLayer what i should use ? Do you have any idea ?

Probably you should rewrite it with hooks. Something like this:

const HeatLayer = (props: Props) => {
  const map = useMap();

  useEffect(() => {
    const { data, ...options } = props;

    const heatLayer = Leaflet.heatLayer(data, options);
    map.addLayer(heatLayer);
    return () => {
      map.removeLayer(heatLayer);
    };
  }, [map, props]);
};
export default HeatLayer;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants