Git Product home page Git Product logo

Comments (6)

alexisvincent avatar alexisvincent commented on May 2, 2024 1

@dylanvorster Essentially @m4rcelofs is asking for an example/way to use react-diagrams in a declarative manner. If I understand correctly. Which would add value to the project.

from react-diagrams.

dylanvorster avatar dylanvorster commented on May 2, 2024

I don't know if I'm being genuinely stupid, but I'm not kidding or even remotely joking or being sarcastic when I say I seriously don't understand the issue being talked about here.

My demos render directly into the body because thats the simplest possible way of giving a demo?
The system is treated exactly like any other react widget. Whether you use redux, Mox, JSX, vanilla JS, render on the server, browser, use coffee script, render it with JQuery.. whatever else you think of, is to me completely irrelevant because its just a react widget. The DiagramWidget is the view, and the DiagramModel is the model, if you store the model somewhere in your application, hide the DiagramWidget and then show the DiagramWidget again, with the same model (aka pass the same props in again), the system just continues where it is left off, like any other stateless react widget.

Like JSX is literally just another way of writing the code, it doesn't have any single effect on the functionality of any system that is written with it, which is the primary reason I don't understand what the issue is about. I use this library on multiple pages that are constantly hiding and showing, and have no issue with it doing so...?

So maybe if you could just explain to me what it is you are trying to do, that is not doing what it should be doing, or explain to me with a code example what you want to achieve, but currently can't (and if applicable, explain to me where and why JSX and Redux has anything to do with this) , ill jump onto a fix/implementation right away, or happily discuss options or changes we can make.

But I'm really confused with the subject matter of this issue xD (sorry if it sounds like I'm ranting)

from react-diagrams.

m4rcelofs avatar m4rcelofs commented on May 2, 2024

Well, its really not about anything lacking the lib - apologies if it sounded like that. Its just that I'm fairly new to React (and TypeScript) and it's been a bit difficult for me to get something running in a declarative way, but I'm probably just missing something quite basic.

For instance, the best I figured was this (clone and npm start should show something in localhost:3000), and it indeed does seem that all elements are in the DOM, it just doesn't show anything.

Since it's probably something stupid I'm doing, I figured I'd ask for a JSX example (:

from react-diagrams.

dylanvorster avatar dylanvorster commented on May 2, 2024

Yeah that is probably because you are missing some css (that example is correct). Check that the diagram widget is in fact expanding to the full size of the browser window. My demos import some additional css to make that possible. See this: https://github.com/projectstorm/react-diagrams/blob/master/demos/test.scss

Im not sure if you are doing something similar, but thats potentially the cause. The other thing is that in your example, you have your logic that works with the model, inside your own class, which is akin to saying that your business logic is inside your view, when that logic should really be inside a store (that doesnt rely on your component being mounted or updated.)

Thats why my demos have the logic in the window.onload, its because like any react program, your state of the application should not be stored inside your react widgets. Thats also why its called "React" its so that you can have a user-interface that renders your application state.

from react-diagrams.

dylanvorster avatar dylanvorster commented on May 2, 2024

So i would move this.engine = new DiagramEngine(); and all that logic that is in your constructor, rather into your redux stores, and then simply pass in the diagram model when you want to render it.

from react-diagrams.

m4rcelofs avatar m4rcelofs commented on May 2, 2024

Ha, totally correct - and a totally stupid mistake (forgot to set the parent element as display: flex). Thanks for the other pointers too! I might be bugging you guys a little until I understand the lib better (:

from react-diagrams.

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.