Sending HTML content in API vulnerability risk - reactjs

I have a react application that builds an Editor component dynamically.
One of the fields in this editor is a content editable div that gets from API -json response- a content to be displayed in that div with some of the text highlighted or styled with any other html tags inside.
The user can change this content and I keep sending it back to API and getting it back from API to be displayed accordingly.
But I'm concerned about security, is this a risky vulnerability? How should I act in such a case?

Yes, you have to concern about security. I recommend to use sanitize-html.

Related

What is the correct way to control when/if to show tooltip in mobile app using react native?

I am writing a mobile app and when the user sees some screens of the app for the first time, I would like to show a tooltip, explaining some of the functionality.
For instance, the user navigates to the profile page, and I show a tooltip on the add icon, saying something like "you can add a photo here".
Obviously I dont want to show this tooltip every time the user navigates to the profile page, so what is the correct way of doing so? Is it via redux? Keeping some state like "tooltipWasShown"?
Or should I write a custom hook? Something which checks if the tooltip was shown? (this should happen again via redux I guess)
I dont think it is a unique problem, but I couldn't find any blog posts/examples of what is the way to implement it. Any suggestions are welcome!
You will need to use Async Storage for the save data about tutorial, if user reload app redux will be empty. Or will add isFirstEnter field to user in DB and then check this field

Can React do two-way binding with a URL field?

I have a data visualization tool written with React. I want to make sure that the URL for the page always refers to the view that the user is currently looking at, and that when they e.g. pan and zoom, or change display settings, the URL is updated so that it will take them back to the same view if they visit it in the future.
(Google Maps works like this; as you pan and zoom the coordinates in the URL get updated to point to where you are currently looking.)
React has tools like React Router to access URL path components and query parameters, but they seem mostly to be designed around a normal multi-route single-page application. You might <Link> to a different route, but you aren't meant to end up at a different route every time you change a dropdown, or type a character in a textbox, or drag to pan something. If you did, the number of history entries created would be unmanageable.
Is there anything in React that can be used to two-way bind page state fields and fields in the URL, so that React will keep them in sync for me? I want to be able to, in the middle of interacting with my application, copy-paste the URL into a new browser window, and have at least the most important parts of my application state be restored, even when that state doesn't map cleanly to the idea of being "on a page".

Can a UI be kept rendered even if it does not match its react-router route?

would anybody here know if it's possible to do something like what happens in this screen recording? https://www.dropbox.com/s/snhhbeq8knk5dyc/modal-window-routing.mp4?dl=0
It's about routing a modal window, while keeping the UI underneath intact. Normally I'd say that to achieve this in React router the URL would need to encode both what's behind, and the modal. Maybe with some nesting scheme (e.g. /mainview/settings/general). But Outlook web manages to do so while not reflecting in the URL the view that was present when the modal was fired.
Note in the recording how the URL for the settings modal is the same, regardless of whether you open it from the Drafts or the Sent Items or wherever. However, the view from which you opened is kept rendered, and it's where you go back to when you close the modal.
according to the react-router-dom documentation, the following link lays out the proper way to go about achieving your desired result https://reactrouter.com/web/example/modal-gallery

How to clear thumbnails from a FineUploader Gallery dropzone

I'm using react-fine-uploader in a project that allows users to send files to other users. I have auto-upload disabled and I'm using the Gallery component with thumbnails. Once a user has selected the files he wants to send he clicks a Send button which calls uploadStoredFiles().
Once all the files have been uploaded and a success message was displayed I want to clear the dropzone so the user can start over and send more files somewhere else.
I can't figure out how to do that. FineUploader has a reset() method that seems to reset the internal state but the thumbnails remain in the dropzone. They are rendered as <li>s in a <ul> so I could just delete those from the DOM but this being a react app that seems wrong.
Is there a proper way to do this?
this should work even out of scope:
Dropzone.forElement("#idOfDropzone").removeAllFiles(true);

Annotating or fetching selected text content using React

I'm trying to build a chrome extension using React and I could not figure out how I can get selected web content into my extension app. I am going to use it for creating annotations on the web content.
To give an example, User visits a web page, selects a text or whole paragraph and the extension will be able to get the content of selected text. I am going to highlight the text and show the user comment then. (e.g. medium.com's annotation model)
I've tried AnnotatorJS but I cannot annotate the content outside of my application context.
What can be the accurate way for implementing annotations in React?

Resources