1.0.0 • Published 4 years ago

@bumped-inc/gatsby-plugin-optional-chaining v1.0.0

Weekly downloads
3,126
License
MIT
Repository
github
Last release
4 years ago

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