Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
babel-plugin-realar
Advanced tools
Readme
Automatic observe jsx arrow functions for smartify and purify your code :+1:
That plugin for babel wraps all not wrapped arrow functions (that contains JSX) to Realar observe
function (but possible for configure to custom one). Less code more effectiveness!
import React, { /* memo */ } from 'react';
import { box, shared, /* observe */ } from 'realar';
class Ticker {
@box value = 0;
next = () => this.value += 1;
}
const sharedTicker = () => shared(Ticker);
// const App = memo(observe(() => {
const App = () => {
const { value, next } = sharedTicker();
return (
<>
Ticker: {value}
<br />
<button onClick={next}>Next</button>
</>
);
};
See wrapped version on CodeSandbox.
You are no need more to wrap (decorate) JSX components to observe
function! It will be automatic.
exclude - array of matcher patterns that needs to exclude.
include - array of matcher patterns that need to include, other ones will be excluded.
// .babelrc.js
module.exports = {
"plugins": [
["realar", {
"include": [
"src/components/*",
"src/pages/*"
],
// "exclude": ["node_modules/*"]
}]
]
};
root - string that provide root path for "exclude" and "include" options.
memo - boolean flag. Wrap all react arrow function React component to React.memo
. If "decorator" property is not used will be true
by default.
decorator - function name that used instead of observe
function from Realar. (For example: "require('mobx').observer")
npm i --save-dev babel-plugin-realar
# or
yarn add babel-plugin-realar
And update your babel config:
// .babelrc
{
"plugins": [
"realar"
]
}
Enjoy and happy coding!
FAQs
Automatic observe jsx arrow functions for Realar
The npm package babel-plugin-realar receives a total of 16 weekly downloads. As such, babel-plugin-realar popularity was classified as not popular.
We found that babel-plugin-realar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.