Is there anyway to have React breadcrumbs in VSCode? - reactjs

VSCode has breadcrumbs which is very useful to navigate between tags in a long HTML file. But in a jsx file the breadcrumbs stop when it reaches the return statement, effectively making this feature non-existent in any rendering part of React.
Is there a setting, an extension or anything that solves this problem? I feel like this should've been a thing by now, with React being around for quite some time.
I did find one VSCode extension called React Outline, but the breadcrumbs doesn't update when I move my cursor around. It doesn't seem to have lots of features either.

React Breadcrumbs VsCode extension already does it nicely. It helps see the React component trees and jump to these components with either outline tab or Cmd+shift+. command.

Related

Which one should I use to render the main project in React.js

I created a React project with Yarn Vite and in the main.tsx the <App /> component was called inside a pair of <React.StrictMode></React.StrictMode>.
It is rendering the application normally and everything is working, only thing that bothers me is that all the console.log I use appears twice in the console. I have already changed to nameless tags for example: <></> and to <React.Fragment></React.Fragment>, both of which solve the problem of the console.log appearing duplicate.
I wanted to know which is the most appropriate way to use and what are the differences between these tags.
I read about the <React.StrictMode></React.StrictMode> at https://pt-br.reactjs.org/docs/strict-mode.html and understood that it is used for verifications, but I didn't quite understand which is the most proper one to use.

Emotion CSS prop styling breaks on prefetching Next.js pages

I'm converting an existing React app to use Next.js and I'm having an issue with the production build. I'm using Emotion to add a css prop for styling. The pages in my app render fine until they prefetch links, at which point the styles disappear from the current page. There's some odd intermittent behaviour as well – sometimes when I then refresh the page I can navigate between pages without the styles disappearing but eventually they disappear again. Inspecting the component shows that the value of the css prop has not changed, but the styles are not being applied to the actual element. Has anyone experienced something similar or could point me in the direction of what is causing this?
Checkout my comment on this issue for the library react-select which uses emotion for styling.
https://github.com/JedWatson/react-select/issues/3309#issuecomment-883001216
I was able to get the styled component to render by putting one in _app.tsx and hiding it so it always renders before any other components which may be delayed for one reason or another.
There are a couple other solutions in that thread that may help you as well.

How to Create a React Component in Isolation?

I need to create a popup message component which gets user feedback. Is there any way for me to develop a component like this (some type of dialog/modal probably) without making a new page to test it on?
Like, is there any way for me to develop this individual popup message, or other small components, in isolation, and then later attach them to a larger page component?
Sure you could use an online editor like codesandbox
Or you could use a dedicated create react app for testing / developing a component alone
You can just make the popup component, and add it into your App.js to see if it works as far as working on local workspace goes. you can also try some sort of virtual code editor like codepen, stackblitz, codesandbox, etc, then copy the code over into your workspace.

Issues on Page Transition using Reach-Router, React-Transition-Group and GSAP?

I'm having issues on page transition animation using Reach-Router Not React-Router, GSAP, and React-Transition-Group in combination.
I did research and found example on page-transition animation using Reach-Router and React-Transition-Group
https://reach.tech/router/example/animation
This example uses CSS to animate, But I wanted to animate it with GSAP and it uses is pure JavaScript not CSS. So, it mean I wouldn't need to use TransitionGroup and CSSTransition.
Later on I found another example on page transition animation with GSAP.
https://stackblitz.com/edit/gsap-react-route-animation
But it uses react-router not reach-router. Since react-router and reach-router look almost close to each other. I decide to go on my own experiment starting with GSAP, RTG and React-Router so I can have better understanding how it work... Here's my sandbox.
https://codesandbox.io/s/react-router-gsap-pgu24
Animation worked! Then, I did another experiment getting exactly copy of code and convert some area to make it compatible with Reach-Router. Here's my sandbox.
https://codesandbox.io/s/reach-router-gsap-h5rny?fontsize=14
Everything works except for animation. Its been struggling for me to find what's the problem and I not understanding here. Did I missing something? Please need help?

How to reinitialise init(); in React to allow Adobe Animate SVG file to rerun upon route change?

I have set up a simple react project that has a reusable component called 'cover'. Within the 'cover' component, I have an animated SVG I created from Adobe Animate and have it exported into HTML, JS and SVG. This works fine on first load as the JS is in the public/index.html file and initialised in the tag. However, when I change routes, the init isn't retriggered (which is correct since React isn't meant to reload the page), so now I have the dilemma of not being able to see the SVG upon route changes.
See example here: https://react-sfj7qx.stackblitz.io
Editor version: https://stackblitz.com/edit/react-sfj7qx
Note that the init() function on the tag doesn't seem to render within Stackblitz...
Since I don't know Adobe Animation too much, I edited your stackblitz, I break your code a little bit, but you have all it needs to succeed in this code. What you was not aware of, is that you need to import and export function and variable between files in react. So you'll see how I've done it in the stackblitz example.
Good luck!

Resources