Skip to content

Roadmap for v2 #11

Closed as not planned
Closed as not planned
@himself65

Description

@himself65

our @textea/json-viewer is based on mac-s-g/react-json-view, which haven’t been maintained since about 2 years ago. Also, the way of writing a react component has changed since then.

So, in v2 version, we will firstly rewrite the whole project using TypeScript and React Hooks.

Secondly, our team’s product(closed alpha for now) is also using json-viewer, we need customize json style in many cases. We need also improve the styling system, my currently plan is to use @mui/material which is a popular library.

Third, is store, I’ve read the whole source code, the previous author stores a value using likeglobalStore.set/get(randomID, key, value, defaultValue) (https://github.com/mac-s-g/react-json-view/blob/master/src/js/stores/ObjectAttributes.js). Also, in many cases, many fields like defaultValue are bypass through the whole component lifecycle. We need refactor this part into a lightly structure using ReactContext, Zustand.

What’s more, a guy suggests me to support plugin system. I’m also thinking this at the beginning. I would prefer a API like:

const types = {
  …jsonViewer.types,
  // support hook with your component
  Number: // MyNumberComponent
}
<JsonViewer
  types={types}
  keyRenderer=((paths: string[], value: unknown, type: Type) => {  })
  valueRenderer=((value: unknown, paths: string[], type: Type) => {  })
>

What’s more, I don’t want it just stop by a JSON viewer. In a real production, we will have many class instance or something more than a string, like images.

const json = {
  type: ‘image’,
  image: ‘base64:xxx’,
  error: new Error(‘something not good’)
}

return (
<JsonViewer
  src={json}
  types={{
    …jsonViewer.types,
    Image: [
      (t) => isBase64(t), // whether this is a image
      (props) => <Image src={props.value}/> // load image
    ],
    Error: [
      (t) => t instanceof Error,
      props => props.value.message // fallback to ‘something not good’
    ]
  }}
/>
)

P.S. This is inspired by https://www.npmjs.com/package/typeson

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions