mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-02-18 12:30:50 +03:00
prettier write
This commit is contained in:
parent
038f30ecc1
commit
27075b1e43
|
@ -81,16 +81,17 @@ class ActionPreview<S, A extends Action<string>> extends Component<
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
tabName: DEFAULT_STATE.tabName,
|
tabName: DEFAULT_STATE.tabName,
|
||||||
};
|
};
|
||||||
copyToClipboard = () => {
|
copyToClipboard = (path: (string | number)[]) => {
|
||||||
try {
|
try {
|
||||||
const deepCopiedObject = cloneDeep(this.props.nextState);
|
const objectByPath = path.reduce((obj: any, key) => (obj && obj[key] !== undefined) ? obj[key] : null, this.props.nextState);
|
||||||
const jsonString = JSON.stringify(deepCopiedObject, null, 2);
|
const jsonString = JSON.stringify(objectByPath, null, 2);
|
||||||
void navigator.clipboard.writeText(jsonString);
|
void navigator.clipboard.writeText(jsonString)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to copy: ', err);
|
console.error('Failed to copy: ', err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
render(): JSX.Element {
|
render(): JSX.Element {
|
||||||
const {
|
const {
|
||||||
delta,
|
delta,
|
||||||
|
@ -230,7 +231,7 @@ class ActionPreview<S, A extends Action<string>> extends Component<
|
||||||
})}
|
})}
|
||||||
onClick={event => {
|
onClick={event => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.copyToClipboard();
|
this.copyToClipboard([...inspectedPath.slice(0, inspectedPath.length - 1), key]);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{'(copy)'}
|
{'(copy)'}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user