@@ -69,10 +69,29 @@ const updateMarkerCluster = (
6969 props : MarkerClusterControl ,
7070 prevProps : MarkerClusterControl ,
7171) => {
72- //TODO when prop change update instance
73- // if (props. !== prevProps.center || props.size !== prevProps.size) {
74- // instance.setBounds(getBounds(props))
75- // }
72+ const { clusterProps, clusterEvents } = getPropsAndEvents ( props )
73+ const { clusterProps : prevClusterProps , clusterEvents : prevClusterEvents } =
74+ getPropsAndEvents ( prevProps )
75+
76+ // Update Options
77+ Object . keys ( clusterProps ) . forEach ( ( key ) => {
78+ if ( clusterProps [ key ] !== prevClusterProps [ key ] ) {
79+ // eslint-disable-next-line
80+ // @ts -ignore
81+ instance . options [ key ] = clusterProps [ key ]
82+ }
83+ } )
84+
85+ // Update Events
86+ Object . entries ( prevClusterEvents ) . forEach ( ( [ eventAsProp , callback ] ) => {
87+ const clusterEvent = `cluster${ eventAsProp . substring ( 2 ) . toLowerCase ( ) } `
88+ instance . off ( clusterEvent , callback )
89+ } )
90+
91+ Object . entries ( clusterEvents ) . forEach ( ( [ eventAsProp , callback ] ) => {
92+ const clusterEvent = `cluster${ eventAsProp . substring ( 2 ) . toLowerCase ( ) } `
93+ instance . on ( clusterEvent , callback )
94+ } )
7695}
7796
7897const MarkerClusterGroup = createPathComponent < L . MarkerClusterGroup , MarkerClusterControl > (
0 commit comments