Skip to content

Commit

Permalink
Rename NativeElement terms to HostInstance in the frontend
Browse files Browse the repository at this point in the history
The highlight ones are generic.

There's a lot of references to Native in the StyleEditor but that one is
indeed referring to React Native.
  • Loading branch information
sebmarkbage committed Jul 27, 2024
1 parent df636e3 commit f70f4c3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import InspectedElementStyleXPlugin from './InspectedElementStyleXPlugin';
import InspectedElementSuspenseToggle from './InspectedElementSuspenseToggle';
import NativeStyleEditor from './NativeStyleEditor';
import ElementBadges from './ElementBadges';
import {useHighlightNativeElement} from '../hooks';
import {useHighlightHostInstance} from '../hooks';
import {enableStyleXFeatures} from 'react-devtools-feature-flags';
import {logEvent} from 'react-devtools-shared/src/Logger';
import InspectedElementSourcePanel from './InspectedElementSourcePanel';
Expand Down Expand Up @@ -188,8 +188,8 @@ function OwnerView({
isInStore,
}: OwnerViewProps) {
const dispatch = useContext(TreeDispatcherContext);
const {highlightHostInstance, clearHighlightNativeElement} =
useHighlightNativeElement();
const {highlightHostInstance, clearHighlightHostInstance} =
useHighlightHostInstance();

const handleClick = useCallback(() => {
logEvent({
Expand All @@ -209,7 +209,7 @@ function OwnerView({
disabled={!isInStore}
onClick={handleClick}
onMouseEnter={() => highlightHostInstance(id)}
onMouseLeave={clearHighlightNativeElement}>
onMouseLeave={clearHighlightHostInstance}>
<span className={styles.OwnerContent}>
<span
className={`${styles.Owner} ${isInStore ? '' : styles.NotInStore}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import ComponentSearchInput from './ComponentSearchInput';
import SettingsModalContextToggle from 'react-devtools-shared/src/devtools/views/Settings/SettingsModalContextToggle';
import SelectedTreeHighlight from './SelectedTreeHighlight';
import TreeFocusedContext from './TreeFocusedContext';
import {useHighlightNativeElement, useSubscription} from '../hooks';
import {useHighlightHostInstance, useSubscription} from '../hooks';
import {clearErrorsAndWarnings as clearErrorsAndWarningsAPI} from 'react-devtools-shared/src/backendAPI';
import styles from './Tree.css';
import ButtonIcon from '../ButtonIcon';
Expand Down Expand Up @@ -66,8 +66,8 @@ export default function Tree(props: Props): React.Node {
const {hideSettings} = useContext(OptionsContext);
const [isNavigatingWithKeyboard, setIsNavigatingWithKeyboard] =
useState(false);
const {highlightHostInstance, clearHighlightNativeElement} =
useHighlightNativeElement();
const {highlightHostInstance, clearHighlightHostInstance} =
useHighlightHostInstance();
const treeRef = useRef<HTMLDivElement | null>(null);
const focusTargetRef = useRef<HTMLDivElement | null>(null);

Expand Down Expand Up @@ -258,7 +258,7 @@ export default function Tree(props: Props): React.Node {
if (selectedElementID !== null) {
highlightHostInstance(selectedElementID);
} else {
clearHighlightNativeElement();
clearHighlightHostInstance();
}
}
}, [
Expand Down Expand Up @@ -288,7 +288,7 @@ export default function Tree(props: Props): React.Node {
setIsNavigatingWithKeyboard(false);
}, []);

const handleMouseLeave = clearHighlightNativeElement;
const handleMouseLeave = clearHighlightHostInstance;

// Let react-window know to re-render any time the underlying tree data changes.
// This includes the owner context, since it controls a filtered view of the tree.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import NoCommitData from './NoCommitData';
import CommitFlamegraphListItem from './CommitFlamegraphListItem';
import HoveredFiberInfo from './HoveredFiberInfo';
import {scale} from './utils';
import {useHighlightNativeElement} from '../hooks';
import {useHighlightHostInstance} from '../hooks';
import {StoreContext} from '../context';
import {SettingsContext} from '../Settings/SettingsContext';
import Tooltip from './Tooltip';
Expand Down Expand Up @@ -101,8 +101,8 @@ function CommitFlamegraph({chartData, commitTree, height, width}: Props) {
useState<TooltipFiberData | null>(null);
const {lineHeight} = useContext(SettingsContext);
const {selectFiber, selectedFiberID} = useContext(ProfilerContext);
const {highlightHostInstance, clearHighlightNativeElement} =
useHighlightNativeElement();
const {highlightHostInstance, clearHighlightHostInstance} =
useHighlightHostInstance();

const selectedChartNodeIndex = useMemo<number>(() => {
if (selectedFiberID === null) {
Expand Down Expand Up @@ -134,9 +134,9 @@ function CommitFlamegraph({chartData, commitTree, height, width}: Props) {
);

const handleElementMouseLeave = useCallback(() => {
clearHighlightNativeElement(); // clear highlighting of element on mouse leave
clearHighlightHostInstance(); // clear highlighting of element on mouse leave
setHoveredFiberData(null); // clear hovered fiber data for tooltip
}, [clearHighlightNativeElement]);
}, [clearHighlightHostInstance]);

const itemData = useMemo<ItemData>(
() => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import HoveredFiberInfo from './HoveredFiberInfo';
import {scale} from './utils';
import {StoreContext} from '../context';
import {SettingsContext} from '../Settings/SettingsContext';
import {useHighlightNativeElement} from '../hooks';
import {useHighlightHostInstance} from '../hooks';
import Tooltip from './Tooltip';

import styles from './CommitRanked.css';
Expand Down Expand Up @@ -99,8 +99,8 @@ function CommitRanked({chartData, commitTree, height, width}: Props) {
useState<TooltipFiberData | null>(null);
const {lineHeight} = useContext(SettingsContext);
const {selectedFiberID, selectFiber} = useContext(ProfilerContext);
const {highlightHostInstance, clearHighlightNativeElement} =
useHighlightNativeElement();
const {highlightHostInstance, clearHighlightHostInstance} =
useHighlightHostInstance();

const selectedFiberIndex = useMemo(
() => getNodeIndex(chartData, selectedFiberID),
Expand All @@ -116,9 +116,9 @@ function CommitRanked({chartData, commitTree, height, width}: Props) {
);

const handleElementMouseLeave = useCallback(() => {
clearHighlightNativeElement(); // clear highlighting of element on mouse leave
clearHighlightHostInstance(); // clear highlighting of element on mouse leave
setHoveredFiberData(null); // clear hovered fiber data for tooltip
}, [clearHighlightNativeElement]);
}, [clearHighlightHostInstance]);

const itemData = useMemo<ItemData>(
() => ({
Expand Down
8 changes: 4 additions & 4 deletions packages/react-devtools-shared/src/devtools/views/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ export function useSubscription<Value>({
return state.value;
}

export function useHighlightNativeElement(): {
clearHighlightNativeElement: () => void,
export function useHighlightHostInstance(): {
clearHighlightHostInstance: () => void,
highlightHostInstance: (id: number) => void,
} {
const bridge = useContext(BridgeContext);
Expand All @@ -361,12 +361,12 @@ export function useHighlightNativeElement(): {
[store, bridge],
);

const clearHighlightNativeElement = useCallback(() => {
const clearHighlightHostInstance = useCallback(() => {
bridge.send('clearHostInstanceHighlight');
}, [bridge]);

return {
highlightHostInstance,
clearHighlightNativeElement,
clearHighlightHostInstance,
};
}

0 comments on commit f70f4c3

Please sign in to comment.