informed
Version:
A lightweight framework and utility for building powerful forms in React applications
31 lines (28 loc) • 904 B
JavaScript
import React, { useEffect } from 'react';
import { useFormState } from '../hooks/useFormState.js';
var Debug = function Debug(props) {
var formState = useFormState();
var displayState = {};
if (Object.keys(props).length > 0) {
Object.keys(props).forEach(function (key) {
displayState[key] = formState[key];
});
} else {
displayState = formState;
}
useEffect(function () {
var _window;
// eslint-disable-next-line
if ((_window = window) !== null && _window !== void 0 && _window.Prism) Prism.highlightAll();
}, [displayState]);
var content = JSON.stringify(displayState, null, 2);
if (props.label) {
content = "// ".concat(props.label, "\n") + content;
}
return /*#__PURE__*/React.createElement("pre", {
className: "language-js"
}, /*#__PURE__*/React.createElement("code", {
className: "language-js"
}, content));
};
export { Debug };