Skip to content

Add react-require to avoid importing React #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 28, 2016

Conversation

jonaswindey
Copy link
Contributor

@jonaswindey jonaswindey commented Nov 26, 2016

This PR will allow a component to work without importing React each time, as discussed in #285

component.js

before:

import React from 'react'

export default () => <div>My component</div>

after:

export default () => <div>My component</div>

@jonaswindey
Copy link
Contributor Author

If this is accepted we can also remove all import statements from the stateless functional components in the /examples

@arunoda
Copy link
Contributor

arunoda commented Nov 26, 2016

@jonaswindey This is great.
But in the future, Next.js will have a config file (next.config.js) which allows you to customize babel plugins (loaders, etc) use in your app.

So, this can be something we could do in the user land.

@jonaswindey
Copy link
Contributor Author

Yep, but I think we can add this as default babel setting in my opinion.. unless you disagree I don't see any disadvantage to use this

@rauchg
Copy link
Member

rauchg commented Nov 26, 2016

I think it's a good default. One thing I'd like us to think about though @jonaswindey is how we're going to be able to neatly override these for #20. Maybe we can have a set of react-specific transformations (like a babel bundle) that can be replaced with another set from another project (like preact)

@rauchg
Copy link
Member

rauchg commented Nov 26, 2016

By the way, have you verified that import React from 'react' in addition still works? We need it for the stateful components

@rauchg
Copy link
Member

rauchg commented Nov 26, 2016

Other than that, +1

@jonaswindey
Copy link
Contributor Author

jep, adding import React from 'react' will still work. No conflicts there.

@rauchg rauchg merged commit 10b815b into vercel:master Nov 28, 2016
@rauchg
Copy link
Member

rauchg commented Nov 28, 2016

Awesome!

@jonaswindey jonaswindey deleted the react-require branch November 28, 2016 12:26
@rauchg rauchg mentioned this pull request Dec 6, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants