Skip to content

NextJS: Cannot assign to read only property 'params' of object '#<Object>' #1164

@hadyjsc

Description

@hadyjsc

I put react-leaflet on my NextJS project, i just write the simple code based on example in new component. And then show error Cannot assign to read only property 'params' of object '#<Object>' after i call the component . Actually the maps is rendered, but the issue is show in the debugging mode, can help me to check the issue is on react-leaflet package or leaflet.

// CoordinatePicker.tsx
'use client';

import React, { useState } from "react"
import { MapContainer, TileLayer, Marker, Popup, useMapEvents } from "react-leaflet"
import 'leaflet/dist/leaflet.css';

const LocationMarker: React.FC<{}> = ({ }) => {
    const [position, setPosition] = useState(null)
    
    const map = useMapEvents({
        click() {
            map.locate()
        },

        locationfound(e: any) {
            setPosition(e.latlng)
            map.flyTo(e.latlng, map.getZoom())
        },
    })

    return <>
        {position === null ? null : (
            <Marker position={position}>
                <Popup>You are here</Popup>
            </Marker>
        )}
    </>
}

const CoordinatePicker: React.FC<{}> = ({ }) => {
    return <>
            <MapContainer
                style={{ height: "250px" }} 
                center={{ lat: 51.505, lng: -0.09 }}
                zoom={13}
                scrollWheelZoom={false}>
                <TileLayer
                    attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
                    url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
                />
                <LocationMarker />
            </MapContainer>
    </>
}

export default CoordinatePicker;
console-dev.js:111   TypeError: Cannot assign to read only property 'params' of object '#<Object>'
    at fulfillReference (app-page.runtime.dev.js:2:346413)
    at wakeChunk (app-page.runtime.dev.js:2:339320)
    at initializeModelChunk (app-page.runtime.dev.js:2:342719)
    at resolveModelChunk (app-page.runtime.dev.js:2:341915)
    at processFullStringRow (app-page.runtime.dev.js:2:376807)
    at app-page.runtime.dev.js:2:379228
    at processBinaryChunk (app-page.runtime.dev.js:2:379300)
    at progress (app-page.runtime.dev.js:2:380828)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at process.processImmediate (node:internal/timers:454:9)
    at process.callbackTrampoline (node:internal/async_hooks:130:17)

installed package

next: ^15.4.6
leaflet: ^1.9.4
react-leaflet: ^5.0.0-rc.2
@types/leaflet: "^1.9.20"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions