GithubHelp home page GithubHelp logo

Comments (1)

esbullington avatar esbullington commented on August 15, 2024

Yes, I'd like to start splitting the components into their own files. I should have some time this week to work on all this. Putting one major component per file is probably a good idea, just like you've done above.

In my own React projects, I've taken to using a single directory per major component (per major feature). They sometimes will contain a few subcomponents in them, and then the main component in a view.js file. I then put functions not directly tied to component logic in a controllers.js file. I then add an index.js file pointing to the view.js file, so I can import the component by its directory name (all this is using commonjs). I've been meaning to write a blog post about it, it works well for large scale projects in React.

We don't have to adopt that structure here, but I do like keeping my non-view-related logic out of the files that contain the components in larger projects. This approach also helps me keep the React state use to a minimum since none ofl the functions in the controllers.js file are state dependent -- all of these functions are pure.

I'd prefer to avoid the .react.js extension. If they're meant to indicate files containing jsx, I'd prefer to just use .jsx, since it seems more widely accepted (such as in Facebook's example projects).

from react-d3.

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.