Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. React
  4. Object Oriented React

Object Oriented React

Scheduled Pinned Locked Moved React
5 Posts 4 Posters 93 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • realJSOPR Offline
    realJSOPR Offline
    realJSOP
    wrote last edited by realJSOP
    #1

    Does anyone use OOP in their react apps? Does it make it easier?

    The app I'm working on right now is implemented using function programming, and after 30 years of OOP dev work, I find it frustrating to have to go what I feel is backwards.

    Graeme_GrantG 1 Reply Last reply
    0
    • A Offline
      A Offline
      Andre Oosthuizen
      wrote last edited by
      #2

      I am not versed in React but I do know that it uses component-based structures (which is the new OOP I believe). You can apply OOP but that is outside my scope.

      1 Reply Last reply
      0
      • realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote last edited by
        #3

        I'm talking about the use of classes. Our app makes very limited use of them, and very few examples exist on the web. I'm not even sure it would be that practical given the nature of react's rendering scheme...

        1 Reply Last reply
        0
        • honey the codewitchH Offline
          honey the codewitchH Offline
          honey the codewitch
          wrote last edited by
          #4

          I wouldn't recommend it. JS and TS aren't really geared for OOP, and while it can support it you'll be swimming upstream. There are cases where you can't really avoid it, like my finite automata JS lib, but prefer functions.

          A component in React is like
          function MyComponent() { ... }

          And react is bit funny about what it expects. For example components I think have to be PascalCase.

          My point is, you may get away with it, but you'll be in for some surprises along the way probably. Personally, I don't like surprises.

          It's not hard to not use OOP and prefer functions. It just takes a little practice. It's not so much learning new things as it is paring what you know. It's worth doing, or you're going to be spending a lot of your time pounding square pegs into round holes.

          1 Reply Last reply
          0
          • realJSOPR realJSOP

            Does anyone use OOP in their react apps? Does it make it easier?

            The app I'm working on right now is implemented using function programming, and after 30 years of OOP dev work, I find it frustrating to have to go what I feel is backwards.

            Graeme_GrantG Offline
            Graeme_GrantG Offline
            Graeme_Grant
            wrote last edited by
            #5

            @realJSOP I have done some OOPs with TypeScript, but the JavaScript generated wasn't so much.

            I googled to see articles on pros and cons:

            1. typescript and pure OOPs concepts
            2. react, typescript and pure oops concepts

            There are some interesting articles on these two searches. It looks possible with TypeScript, while JavaScript is primarily a prototype-based language.

            “I fear not the man who has practised 10,000 kicks once, but I fear the man who has practised one kick 10,000 times.” - Bruce Lee.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups