I have taken several react courses that walk through building applications. The courses teach syntax and concepts. But how you solve a problem using react is different!
I am a dinosaur web person who is used to html/javascript.
In terms of a real-world example, such an enterprise level component, how do you tackle it? Do you follow a process where you write pseudo code first? Do you start with writing your code all in one file, and then break them into their own components?
I was going to try to create a modal component (I am sure they exist in a million places already) but for the sake of understanding, but I immediately get hung up in my own confusion.
If you need to use some simple components like modals, buttons etc., you can use one of the popular component libraries like Material UI.
Apologies if I don't explain this well, but I've seen something like this on certain websites (unfortunately can't think of an example right now).
Sometimes if I visit a website for the first time, the site will guide me through the entire document and highlight certain sections e.g., "Use this button here to add a new item" while the rest of the page is greyed out, and then you click Next step which takes you to the next feature, and so on.
It'll be somewhat similar to this (but styled nicer) :
Is there a way (or package) to do this with React?
I believe this feature is called Product Tours
This library can help you - https://github.com/gilbarbara/react-joyride
Also, I found an article using this library on Smashing Magazine - https://www.smashingmagazine.com/2020/08/guide-product-tours-react-apps/
I am using jointJS as a diagramming library. It creates nodes on a graph using svg elements.
I want to use react to render the content of those nodes, and since jointJS lets me configure what svg element i want it to use, all I have to do is
Configure jointJS so it knowns a node is a <foreignObject>
Retrieve that foreign object, and mount a react component inside of it using createPortal
Dynamically size the foreign object so it fits the react component.
It works fine, but I don't have enough experience with foreignObject to know if any caveats are to be expected.
Can anyone provide some feedback about their experience with such practices ?
Answering my own (old) question feels a bit like:
If you're reading this because you're faced with a similar issue, my advice is to avoid being in this situation in the first place.
Some standard CSS features will behave inconsistently, won't work at all, or will have very different outputs depending on the browser you're using.
If I remember correctly, transform and opacity are the two main problematic properties.
Also, animating those properties will rarely work at first try.
Perhaps this is such an edge case that browser bugs are not often found and reported. (and probably not prioritised).
We ended up developing a flowchart library that natively uses react to display nodes.
Cheers!!
I'm currently working on a project where a situation has come up that I haven't experienced before and not sure I know the best way to handle it. I am looking to have one parent react application that would handle my navigation (with react-router) throughout the different pages of the app and also the login/authentication.
Then in the same repository I would be looking to have multiple other react applications that would render whenever clicked on the from the navigation menu in the parent application, with the navigation menu always remaining on the page.
Does anyone have any good suggestions on how to accomplish this. Maybe even with only one build process (not a necessity, but a nice to have)
I think you are after a micro front end.
You could take a look at https://github.com/CanopyTax/single-spa/tree/master/examples
This is a great project with lots of potential. Unfortunately , I haven't been able to use it since my company insists on using create-react-app and version 2 has been problematical when trying to use the library with it.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Let's assume that I am a decent JS programmer. I can easily do React.js development. I also can write HTML and CSS to some extent. I cannot, however, build a webpage from the ground up, i.e. define the HTML structure (say in terms of React components or just plain HTML), add some CSS and get the all-shiny responsive modern-looking fancy webpage. So, I work with a designer, who uses some sort of black magic (or maybe a WYSIWYG tool, or a service like wix.com) to prototype a web page.
So, what I get is a bunch of html files, images, css styles and maybe a bit of javascript.
Now I need to convert all this into a component hierarchy of React. I'm sure I can do this, and after the job is done, I get a shiny new website, beautiful from the technological and aesthetical point of view.
However, we all know that we work in Agile environments. Later on, a designer wants me to change something. 'Add a black border' he says. And here things go out of control.
Should I do this (manually look up the style in css and add a border)? What if changes required are more complicated? Like swap a header and a footer?
Should he do this? (regenerate those source htmls/css/images again) What happens after that? Should I diff the whole website to learn what have changed and reimplement the whole component structure to reflect changes?
Are there any accepted methodologies to solve this evil circle? Maybe a tool that maps the input ugly html code to the properly done React code?
Or maybe I am totally wrong and I should learn the art of design myself?
Edit: Ok, as everybody is misundestanding the question, here is the shorter version. If the Templater changes the templates already implemented in React site, what can I do except manually diff and patch all the changes to the source css/html files?
What you're sounds a bit sketchy to me. You have to know CSS and HTML if you want to build a website, and especially maintain it. The designer probably won't be here forever for you and you would end-up in a difficult position.
The kind of flow you describe, where the designers creates all the structure and gives you the full html and css code was only working in the age of jQuery. The plug of your scripts were pretty easy and didn't required much changes, since it was decoupled from the actual html and you would use dom ids for the targeting.
How it works at Uber, but I'm sure in a lot of other companies, is that the designer is in charge of the design, but that's it, the rest is up to you. You have to make a second pass after him for the actual implementation.
Since reproduction can be pretty difficult and approximative, you can use Invision, where the designer will create the mockups, but you as a developer can get all the css properties of an element, making the integration much easier to do (dunno if wix has the same kind of feature).
If your designer updates a part of the design, it becomes straight-forward for you to know what changed and what component needs to be updated. That's one of the benefits of owning the code rather than taking one from someone else (especially if it was automatically generated).
Get the html files
Create the Router in React
Migrate the basic Layout stuff into a Layout Component
Migrate the pages content into PagesComponents
Migrate common components into your ComponentsLibrary (Navs, Buttons, etc.)
Replace the common html parts with the newly created Components
Apply logic, and so on. Refactoring, refactoring, refactoring... :)
Usually, I am asking the Templater/HTML to put their work into ReactComponents, for this I setup a simple empty React Application, with Routes definitions, and work with them, it will definitely save you a lot of time, because you can apply some logic in parallel or rethink some parts of your application, and ask for changes.
To be real efficient, they should just start by creating a pure-components library, where every component and the styles for it are isolated from the rest of the application, let them put the default values inside, and then let them use props, after the pure components are done, you can orchestrate your application with containers and logic.
The first flow you mentioned is OK, when you get only plane html and css pages from the designer/html coder.
If you are planing to create those pages with react/angular/vue whatever...
you don't need any javascript from the designer.
The steps you will need to take:
1) get html and css from designer
2) design on paper your blocks to components: header, navbar, sidebar, mainContent, footer, PostsList, Post, CommentsList, Comment, etc
3) Start building those components one by one
*Let's assume we are using react
4) make sure each component is stand alone, and extensible, for easy update in the future.
5) Make sure you have tests! Learn TDD
6) ship your app
Next cycles for updates...
1) Your designer gives you new designed pages
2) you can use the designer html and css *PARTLY and use that in your code
3) make sure you extend your components or update properly
4) tests should still work properly
Some notes before you start diving in to all that work:
learn html, css and how to build simple pages properly
you can try bootstrap it is super easy to use
learn react (if thats is what you want to use)
you will need to build your code, so you will need webpack or whatever tool.
But there is much more work ahead, so good luck it's fun! :)
This sounds like a question somebody coming from a php programming background wokring with templates would ask. React works very differently and if you wanted to be in a position where you had a base site and wanted to make changes to it going forwards you would need to have a development environment setup so that once you have made your changes, you would then 'run a build' which would produce your bundled minified javascript file, from the source code in your development environment, ready for production which you would then push to the server as you would with any site.
The reason working like this is considered the way forward is becuase it is so easy to decouple your sites logic from its aestetic. So adding a border to an element becomes as easy as adding a line of css, running your build, uploading the latest version of your app to the server and its done. As long as its written correctly to begin with you should be able to work with confidence that a visual change will only affect your site visually. Changing a classname or moving an element wont break the logic because the logic should be either in your store/actions (redux/flux store method) or local to your components code (functional component).