Let say that your backend framework is Django or Rails. The data you get and send must be in snake_case because this is the convention in these frameworks.
How can you solve this without making your Linter go mad? Should you break the convention for either Rails or React?
If you don't mind breaking name conventions, go ahead and use snake case in your React App (sorry Linter! 💔)
For the rest of us, I have a solution:
- after retrieving data from your backend, transform it to camelCase
- before sending data to your backend, transform it to snake_case
Why in client code you might ask? Well, because 99% of the time you will be adding somekind of fetch wrapper in your app (for example, to transform the responses to JSON). Just extend it a little.
Show me the code
after retrieving data from your backend, transform it to camelCase
before sending data to your backend, transform it to snakeCase
Then in your React components use your new functions and you're done!
Why it works
- Most React apps needs some-kind of wrapper for requests. It could be to transform all requests to JSON, to add authentication tokens, etc. So extending the wrapper a little for transformations is okay and straightforward.
- Sometimes you won't be able to touch your backend code. In this case, any transformation should be done in client (React) anyway.