Skip to content

Commit

Permalink
fix: forward map ref
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaclennan committed Oct 7, 2019
1 parent a7a6169 commit 005a454
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
27 changes: 17 additions & 10 deletions src/MapView/MapView.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
// @flow
import React from 'react'

import MapViewContent, { type MapViewContentProps } from './MapViewContent'
import MapViewContent, {
type MapViewContentProps,
type MapInstance
} from './MapViewContent'
import ViewWrapper, { type CommonViewProps } from '../ViewWrapper'

type Props = {
...$Exact<CommonViewProps>,
...$Exact<MapViewContentProps>
}

const MapView = ({
observations,
onUpdateObservation,
presets,
filter,
getMediaUrl,
...otherProps
}: Props) => {
const MapView = (
{
observations,
onUpdateObservation,
presets,
filter,
getMediaUrl,
...otherProps
}: Props,
ref
) => {
return (
<ViewWrapper
observations={observations}
Expand All @@ -26,6 +32,7 @@ const MapView = ({
getMediaUrl={getMediaUrl}>
{({ onClickObservation, filteredObservations, getPreset, getMedia }) => (
<MapViewContent
ref={ref}
onClick={onClickObservation}
observations={filteredObservations}
getPreset={getPreset}
Expand All @@ -37,4 +44,4 @@ const MapView = ({
)
}

export default MapView
export default React.forwardRef<Props, MapInstance>(MapView)
4 changes: 2 additions & 2 deletions src/MapView/MapViewContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Props = {
print?: boolean
}

type Instance = {
export type MapInstance = {
fitBounds: () => any,
flyTo: () => any
}
Expand Down Expand Up @@ -263,7 +263,7 @@ const MapViewContent = (
)
}

export default React.forwardRef<Props, Instance>(MapViewContent)
export default React.forwardRef<Props, MapInstance>(MapViewContent)

function getBounds(
observations: Observation[]
Expand Down

0 comments on commit 005a454

Please sign in to comment.