Skip to content

Commit

Permalink
fix: enableReactTracking renamed warnGet to warnMissingUse
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeistrich committed Dec 3, 2024
1 parent fdf3f84 commit b1dbea4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/config/enableReactTracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as ReactInternals }
interface ReactTrackingOptions {
auto?: boolean; // Make all get() calls act as useSelector() hooks
warnUnobserved?: boolean; // Warn if get() is used outside of an observer
warnGet?: boolean; // Warn if get() is used in a component
warnMissingUse?: boolean; // Warn if get() is used in a component
}

export function enableReactTracking({ auto, warnUnobserved, warnGet }: ReactTrackingOptions) {
export function enableReactTracking({ auto, warnUnobserved, warnMissingUse }: ReactTrackingOptions) {
const { get } = internal;

if (auto || (process.env.NODE_ENV === 'development' && (warnUnobserved || warnGet))) {
if (auto || (process.env.NODE_ENV === 'development' && (warnUnobserved || warnMissingUse))) {
const ReactRenderContext = createContext(0);

const isInRender = () => {
Expand Down Expand Up @@ -45,7 +45,7 @@ export function enableReactTracking({ auto, warnUnobserved, warnGet }: ReactTrac
configureLegendState({
observableFunctions: {
get: (node: NodeInfo, options?: TrackingType | (GetOptions & UseSelectorOptions)) => {
if (process.env.NODE_ENV === 'development' && warnUnobserved) {
if (process.env.NODE_ENV === 'development' && warnMissingUse) {
if (isInRender()) {
console.warn(
'[legend-state] Detected a `get()` call in a React component. It is recommended to use the `use$` hook instead to be compatible with React Compiler: https://legendapp.com/open-source/state/v3/react/react-api/#use$',
Expand Down

0 comments on commit b1dbea4

Please sign in to comment.