Giter VIP home page Giter VIP logo

Comments (5)

xabikos avatar xabikos commented on August 30, 2024

Thanks for the feedback OshotOkill.

Regarding the default action of exporting the component with rcc snippet could you give an example when a component is not exported by default? I have in mind the practice of having only one component per file. The only case I can think of is the "smart" components in a redux application. A different set of snippets particularly for redux are in my plans for the near future.

Now about a snippet for a constructor that except props contains also the context is really easy to add. I didn't do it in advance as context is an advance feature and it's usage is discouraged actually but I am happy to add it. I guess that conc is a good candidate.

from vscode-react.

OshotOkill avatar OshotOkill commented on August 30, 2024

Yeah only a single component per file is one of the best practice in React/Redux while not every one intends to implement it, whether they don't have a distinct structure in mind to export which component at the beginning or they just tend to export a component but nested with others, and with that, we have to scroll down to the end line of the file to delete unnecessary export default sentence. That's the reason why I prefer to move export default to another snippet such as rcced, more choice more better.

As to add context parameter in constructor signature, my thought comes with the default constructor
in react

function ReactComponent(props, context, updater) {
  this.props = props;
  this.context = context;
  this.refs = emptyObject;
  this.updater = updater || ReactNoopUpdateQueue;
}

Though context is discourage however it's still being used widely in many project specially passing css-styles into lower components. Since JS extends instance constructor it is a error prone which would cause losing context property. Even if we don't use context at all but add context may enhance the robustness of components. React-Router, Redux already did that.

from vscode-react.

xabikos avatar xabikos commented on August 30, 2024

Thanks for the input. I would prefer not to change the behavior of the existing snippet rcc in order not to confuse existing users but instead add a new one that doesn't export the component by default. But in that case I am just thinking maybe this snippet should not have import statements too to avoid not required import lines in multiple components per file. What do you think of a snippet like rcjc from React create just component?

Now about context constructor parameter I created #9

from vscode-react.

OshotOkill avatar OshotOkill commented on August 30, 2024

Yeah rcjc is ok, we need the way to create just a pure component, so the import statement should be removed as well which I forgot to say (same with stateless component).

Thanks and forgive my wayward requirements.

from vscode-react.

xabikos avatar xabikos commented on August 30, 2024

Implemented in the latest version 0.4.0

from vscode-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.