mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-25 19:13:56 +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 = {
|
||||
tabName: DEFAULT_STATE.tabName,
|
||||
};
|
||||
copyToClipboard = () => {
|
||||
copyToClipboard = (path: (string | number)[]) => {
|
||||
try {
|
||||
const deepCopiedObject = cloneDeep(this.props.nextState);
|
||||
const jsonString = JSON.stringify(deepCopiedObject, null, 2);
|
||||
void navigator.clipboard.writeText(jsonString);
|
||||
const objectByPath = path.reduce((obj: any, key) => (obj && obj[key] !== undefined) ? obj[key] : null, this.props.nextState);
|
||||
const jsonString = JSON.stringify(objectByPath, null, 2);
|
||||
void navigator.clipboard.writeText(jsonString)
|
||||
} catch (err) {
|
||||
console.error('Failed to copy: ', err);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
render(): JSX.Element {
|
||||
const {
|
||||
delta,
|
||||
|
@ -230,7 +231,7 @@ class ActionPreview<S, A extends Action<string>> extends Component<
|
|||
})}
|
||||
onClick={event => {
|
||||
event.stopPropagation();
|
||||
this.copyToClipboard();
|
||||
this.copyToClipboard([...inspectedPath.slice(0, inspectedPath.length - 1), key]);
|
||||
}}
|
||||
>
|
||||
{'(copy)'}
|
||||
|
|
Loading…
Reference in New Issue
Block a user