babel-plugin-arrow-functions-implicit-return
v0.1.1
Published
Arrow functions blocks behave like do expressions
Downloads
21
Maintainers
Readme
Arrow functions implicit return
This plugin allows you to use arrow functions like do expressions.
Examples
const shows = ["Death Note", "Steins;Gate", "Maho shojo XD"];
const nextShow = prevShow => {
const prevIndex = shows.findIndex(show => show === prevShow) || 0;
shows[(prevIndex + 1) % shows.length];
};With JSX
const getUserNav = () => {
<UserConsumer>
{
(user) => {
if(user){
<span>Hello {user.name}!<span>;
} else {
<a onClick={showLogin}>Login</a>;
}
}
}
</UserConsumer>
};Installation
npm install --save-dev babel-plugin-arrow-functions-implicit-returnUsage
Via .babelrc (Recommended)
.babelrc
{
"plugins": ["arrow-functions-implicit-return"]
}Via CLI
babel --plugins arrow-functions-implicit-return script.jsVia Node API
require("babel-core").transform("code", {
plugins: ["arrow-functions-implicit-return"]
});