Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ Optionally you can pass in `options` as the second parameter. The following opti
- `diffNameColor`
- `diffPathColor`
- `notifier: ({Component, displayName, hookName, prevProps, prevState, prevHook, nextProps, nextState, nextHook, reason, options, ownerDataMap}) => void`
- `getAdditionalOwnerData: (element) => {...}`

#### include / exclude
##### (default: `null`)
Expand Down Expand Up @@ -291,6 +292,10 @@ Controls the colors used in the console notifications

You can create a custom notifier if the default one does not suite your needs.

#### getAdditionalOwnerData
##### (default: `undefined`)
You can provide a function that harvests additional data from the original react element. The object returned from this function will be added to the ownerDataMap which can be accessed later within your notifier function override.

## Troubleshooting

### No tracking
Expand Down
7 changes: 7 additions & 0 deletions src/whyDidYouRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,19 @@ export function storeOwnerData(element) {
if (OwnerInstance) {
const Component = OwnerInstance.type.ComponentForHooksTracking || OwnerInstance.type;
const displayName = getDisplayName(Component);

let additionalOwnerData = {};
if (wdyrStore.options.getAdditionalOwnerData) {
additionalOwnerData = wdyrStore.options.getAdditionalOwnerData(element);
}

wdyrStore.ownerDataMap.set(element.props, {
Component,
displayName,
props: OwnerInstance.pendingProps,
state: OwnerInstance.stateNode ? OwnerInstance.stateNode.state : null,
hooks: wdyrStore.hooksPerRender,
additionalOwnerData,
});
}
}
Expand Down