({ auto, warnUnobserved }: ReactTrackingOptions)
| 38 | } |
| 39 | |
| 40 | export function enableReactTracking({ auto, warnUnobserved }: ReactTrackingOptions) { |
| 41 | const { get } = internal; |
| 42 | |
| 43 | configureLegendState({ |
| 44 | observableFunctions: { |
| 45 | get: (node: NodeValue, options?: TrackingType | (GetOptions & UseSelectorOptions)) => { |
| 46 | if (needsSelector()) { |
| 47 | if (auto) { |
| 48 | return useSelector(() => get(node, options), isObject(options) ? options : undefined); |
| 49 | } else if (process.env.NODE_ENV === 'development' && warnUnobserved) { |
| 50 | console.warn( |
| 51 | '[legend-state] Detected a `get()` call in an unobserved component. You may want to wrap it in observer: https://legendapp.com/open-source/state/react-api/#observer-hoc', |
| 52 | ); |
| 53 | } |
| 54 | } |
| 55 | return get(node, options); |
| 56 | }, |
| 57 | }, |
| 58 | }); |
| 59 | } |
| 60 | |
| 61 | // Types: |
| 62 |
nothing calls this directly
no test coverage detected