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.

[Discuss] Best way to separate functions to reuse-able

See original GitHub issue

Hi, I’ve been using react-rails for almost year. I have a lot of modules and files that doing its job but some files and modules used same custom function (repeat code). I would like to know how you guys action with this situation like me.

In my mind just put into the .js file and include its into the application.js file. it’s ok to do so?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
BookOfGregcommented, Jul 10, 2018

I have a utils.js that I require in each JS file that I need it. Must say I’m slightly out of date with the latest trends so idiomatic react might have a different way of doing it. Generally I’m a big fan of the simplest thing that works.

0reactions
BookOfGregcommented, Jul 11, 2018

Going to close for now as I believe this has been answered.

Read more comments on GitHub >

github_iconTop Results From Across the Web

4. Code Reuse: Functions and Modules - Head First Python ...
Take a collection of functions and package them as a file, and you've got a module (which can also be reused). It's true...
Read more >
Functions — reusable blocks of code - Learn web development
In this article we'll explore fundamental concepts behind functions such as basic syntax, how to invoke and define them, scope, and parameters.
Read more >
4 Ways to Make Your Code More Reusable | by Lance Harvie
Plan and identify the parts of your software which needs to be divided into chunks. Divide a software system into multiple independent ...
Read more >
How to Maximize Your Ability to Reuse Code Across Projects
The following are some common ways to identify and implement separate components of reusable code for speedy development, using less time ...
Read more >
Reusable and modular code with functions
Functions wrap up reusable pieces of code - they help you apply the Do Not Repeat Yourself (DRY) principle. Suppose that separating large...
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