microlinkhq / microlinkhq/react-json-view
src cannot be undefined?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 417
- Forks
- 68
- Avg merge
- 4h 22m
- Merged PRs (30d)
- 8
Description
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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the ReactJson component and locate the type declaration for its src prop, then trace how an undefined initial value is handled. Confirm the intended behavior with the supplied delayed useState example and ensure the component accepts the initial undefined value without breaking the later string update.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100