https://github.com/loopmode/react-link
https://github.com/loopmode/react-link
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/loopmode/react-link
- Owner: loopmode
- License: mit
- Created: 2019-08-15T08:04:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-15T15:55:53.000Z (over 6 years ago)
- Last Synced: 2025-02-08T18:02:20.001Z (about 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# @loopmode/react-link
A thin wrapper around the `` tag that allows usage of `javascript:` href.
Currently, React allows this but already prints a deprecation message: `Warning: A future version of React will block javascript: URLs as a security precaution.`
(see [PR 15047](https://github.com/facebook/react/pull/15047))
## Motivation
My original use-case is to render bookmarklets in a react app: Links or buttons users can drag into their browser bookmarks bar. When clicked, these bookmarklets shouldn't navigate; instead, they should execute some function on the current page.
## Installation
```
yarn add @loopmode/react-link
```
```
npm install --save @loopmode/react-link
```
## Usage
Please note that if you're using ESLint, you may still get warnings from the `no-script-url` rule.
There are various ways to disable it, for example you could disable the rule at the top of the file that defines the script url.
```jsx
/* eslint-disable no-script-url */
import React from "react";
import Link from "@loopmode/react-link";
export default function MyBookmarklet() {
return (
exec javascript function
);
}
```