react-json-view
react-json-view copied to clipboard
src cannot be undefined?
In the pervious versions of this component the src property could be set to undefined which is handy in my case as I use this as a debug tool for seeing the internals of my React page. Could we add the undefined type to src? Or am I missing something on how to use this component correctly?
import ReactJson from '@microlink/react-json-view';
import { useEffect, useState } from 'react';
const Foo = () => {
const [value, setValue] = useState<string>();
useEffect(() => {
setTimeout(() => {
setValue('hi');
}, 1000); // Simulate a delay
}, []);
return <ReactJson src={value} />;
};
export default Foo;
Thanks!
try
import ReactJson from '@microlink/react-json-view';
import { useEffect, useState } from 'react';
const Foo = () => {
const [value, setValue] = useState<string>();
useEffect(() => {
setTimeout(() => {
setValue('hi');
}, 1000); // Simulate a delay
}, []);
return <ReactJson src={value || {}} />;
};
export default Foo;