question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add React.createContext to @babel/plugin-transform-react-pure-annotations

See original GitHub issue

Feature Request

  • I would like to work on this feature! (I don’t actually care who works on this, but I’m happy to do it. Whatever is easier.)

Is your feature request related to a problem?

I have a React component library. When consuming applications use the library, a bunch of React.createContext calls are added to the bundle for components that aren’t even being used. This shouldn’t be the case as createContext simply takes in some parameters and returns an object.

Describe the solution you’d like

Super pumped about the new @babel/plugin-transform-react-pure-annotations package. I would like to add React.createContext to this PURE_CALLS map.

https://github.com/babel/babel/blob/71d3527ef580d63a2764a2a96b0072b23195df4f/packages/babel-plugin-transform-react-pure-annotations/src/index.js#L10-L23

Describe alternatives you’ve considered.

Nothing. I’m open to them, but this seems straightforward enough.

Documentation, Adoption, Migration Strategy

Adoption and Migration are simple a npm update. Not sure is this is something that is documented or not. I’m guessing not.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolo-ribaudocommented, Jun 27, 2020

@babel/preset-react uses ^ to specify the version of the plugin, so it can already download the latest one.

0reactions
jessethomsoncommented, Jun 27, 2020

Oh, I totally missed that. Awesome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Context - React
Context provides a way to pass data through the component tree without having to pass props down manually at every level. In a...
Read more >
How to use React Context with TypeScript - LogRocket Blog
To easily create a TypeScript project with CRA, you need to add the flag --template typescript , otherwise the app will only support...
Read more >
Context | React TypeScript Cheatsheets
Using createContext with an empty object as default value. interface ContextState { // set the type ...
Read more >
React Context for Beginners – The Complete Guide (2021)
Create context using the createContext method. Take your created context and wrap the context provider around your component tree. Put any value ...
Read more >
A Guide to React Context and useContext() Hook
The React context provides data to components no matter how deep they are ... The built-in factory function createContext(default) creates a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found