Comments (6)
@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.
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.
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.
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.
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.
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)
- custom code
- [Bug] Right angled links are diagonal if the points are added after the link is created
- 50 Errors in build HOT 2
- BezierCurve
- Tutorial not working HOT 1
- Deserialization not working HOT 2
- Demos should be refactored to be consistent with modern react standards and styles HOT 2
- I can't see the any nodes. HOT 1
- Is there a way with smart routing to ensure that the link line is never going through the node?
- Deregister Listener when links are created
- DragNewLinkState bug when pressing down with another mouse button while dragging.
- Does storm-react-diagrams support nonce attribute for CSP?
- Node EventListeners don't work when setting a state from component
- can't find createEngine export HOT 1
- Adding NodeModel to NodeLayer set itself as its parent, but NodeModel's parent must be a Diagram
- Module '"@projectstorm/react-diagrams"' has no exported member 'AbstractReactFactory'.
- Intermittent bug in dragNewLink with allowLooseLinks = false HOT 2
- Bug: running `diagrams-demo-project` error `TS2345: Argument of type 'Element' is not assignable to parameter of type 'ReactNode'. Property 'children' is missing in type 'Element' but required in type 'ReactPortal'.`
- Deserialization isn't working properly HOT 1
- got an error in gallary demo: diagrams-demo-gallery HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-diagrams.