@bumped-inc/gatsby-plugin-optional-chaining
v1.0.0
Published
Gatsby plugin for optional chaining operator
Downloads
502
Readme
Optional chaining support for Gatsby's Babel config
Description
It enables the optional chaining operator (a ?. b
): see the TC39 proposal
How to install
Install the plugin and its dependencies :
npm i @bumped-inc/gatsby-plugin-optional-chaining @babel/core @babel/plugin-proposal-optional-chaining
or
yarn add @bumped-inc/gatsby-plugin-optional-chaining @babel/core @babel/plugin-proposal-optional-chaining
Add the plugin in gatsby-config.js
:
module.exports = {
plugins: [
// other plugins
'@bumped-inc/gatsby-plugin-optional-chaining',
],
}
Examples of usage
const maybeObj = null;
const result = maybeObj?.value; // result: undefined
const actualObj = { value: 5 };
const betterResult = actualObj?.value // betterResult: 5