Coder Social home page Coder Social logo

React support? about json-editor HOT 14 CLOSED

json-editor avatar json-editor commented on May 22, 2024
React support?

from json-editor.

Comments (14)

butters16 avatar butters16 commented on May 22, 2024 5

I decided to use this in my react code

const JSONEditor = require("@json-editor/json-editor").JSONEditor;

with my entire component looking like this (although it's rough and i'm likely to refactor it as i actually start to develop, but coding practices are not the point of this thread πŸ˜‰)

import React, {useEffect} from 'react';
import schema from "./schema.json"
import "@fortawesome/fontawesome-free/css/all.css"
const JSONEditor = require("@json-editor/json-editor").JSONEditor;

const BuildView = () => {
    useEffect(() => {
        const element = document.getElementById('editor_holder');
        const editor = new JSONEditor(element, {
            schema: schema,
            display_required_only: true, // circular references will blow up without this
            theme: 'bootstrap4',
            iconlib: 'fontawesome5'
        });
    }, []);

    return <div id='editor_holder'></div>
};

export default BuildView;

from json-editor.

pmk65 avatar pmk65 commented on May 22, 2024 3

I don't understand why info like this isn't added to the documentation or wiki?
The same questions pop up again and again because there's no info in the documentation.
Same goes for new features that are not documented. 😞

from json-editor.

marc7000 avatar marc7000 commented on May 22, 2024 2

@Dids yes i can, i had a sample project, but i already deleted it. when i have time, i check it again and add it to the documentation.

from json-editor.

loganvolkers avatar loganvolkers commented on May 22, 2024 1

Mozilla is also sponsoring a popular project: https://github.com/mozilla-services/react-jsonschema-form

from json-editor.

narciero avatar narciero commented on May 22, 2024

The link you posted returns 404...but yea it would be great to have an 'official' react component as part of this lib, id be willing to help contribute.

from json-editor.

schmunk42 avatar schmunk42 commented on May 22, 2024

@loganvolkers Is the Mozilla lib a full replacement for json-editor?

@narciero What would be needed to make this a react-component?

from json-editor.

s-a avatar s-a commented on May 22, 2024

import '@json-editor/json-editor' resolves to object instead of function. I guess there is missing something like an AMD loader in there. Any news on this thread?

from json-editor.

marc7000 avatar marc7000 commented on May 22, 2024

Use import JSONEditor from '@json-editor/json-editor' works with Vue.js and Angular 2.

from json-editor.

s-a avatar s-a commented on May 22, 2024

This does ironically work in react development but not in production build. I use node node_modules/react-scripts/bin/react-scripts.js build to build react app for production deplyoment.

from json-editor.

schmunk42 avatar schmunk42 commented on May 22, 2024

@crisu83 Can you shed some light on this? (since you're working a lot with react)

from json-editor.

crisu83 avatar crisu83 commented on May 22, 2024

@schmunk42 looking at the code it seems that this editor uses jQuery and DOM manipulation, and usually React doesn’t play very nice with DOM manipulation, so I’m not sure.

from json-editor.

schmunk42 avatar schmunk42 commented on May 22, 2024

@crisu83 Thank you for the feedback!

from json-editor.

Dids avatar Dids commented on May 22, 2024

@marc7000 Can you confirm it's supposed to work with Vue? I can partially see editor elements, but it's throwing the following error: TypeError: (new _json_editor_json_editor__WEBPACK_IMPORTED_MODULE_6___default.a(...)) is not a function

UPDATE: Looks like it's actually initializing without errors, and only erroring when trying to call editor.getValue()

UPDATE 2: Never mind, turned out to be unrelated after all. :)

from json-editor.

VadimTikhonyuk avatar VadimTikhonyuk commented on May 22, 2024

@Dids yes i can, i had a sample project, but i already deleted it. when i have time, i check it again and add it to the documentation.

Hi, so where I can find, looks like Wiki page doesn't have article about this

from json-editor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.