Comments (6)
Honestly, I would probably go without Redux-ORM at this point. At the time that I wrote this, there were three reasons to look at using Redux-ORM: 1) automatic normalization, 2) easier immutability than spread syntax, 3) automatic handling of relational data
Now that RTK exists and has createEntityAdapter
, that at least handles the "normalize items" and "easier immutability" cases. However, createEntityAdapter
doesn't do anything for handling relations. So, if you have truly relational data and are always needing to look up relations all the time, then yes, Redux-ORM would still be able to help with that part.
from marks-dev-blog-comments.
Thanks very much for this series. Despite a few years passing it is immensely helpful and versatile (with one tweak)...
I ran yarn upgrade
and everything seemed to be working fine. I then ran yarn upgrade --latest
to take React to v17 and Redux to v4 etc, but had problems with the absolute paths. It took me an embarrassing amount of time to figure out, but in the end supplying a jsconfig.json
file with the following fixed the problem:
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
Seems like the .env
trick is no longer supported by CRA. Just thought I'd mention in case it helps others.
from marks-dev-blog-comments.
Hey, appreciate the feedback!
Yeah, obviously a good chunk of the info in this post series is now outdated. I'd write a lot of the Redux logic very differently today (Redux Toolkit, single-file "slices", hooks instead of connect
, etc), and a lot of the ecosystem has evolved too (no .env
option, Redux-ORM's API changing dramatically, and for that matter Semantic-UI being basically unmaintained).
At the same time, a lot of the principles I described in this series are still relevant: optimizing re-renders based on comparisons, selecting data from the store based on ID, the "modals" technique, splitting reducers.
I wish I had time to go back and update this series, but most of my attention these days is focused on rewriting the actual Redux docs themselves:
In any case, always love hearing that the material I've written is helping folks!
from marks-dev-blog-comments.
Thanks for the quick reply! Throughout reading your series I wondered what you might do differently today. You mention using single-file "slices" and having read the current Redux Essentials guide it led my beginner's brain to ask whether you might try and use createSlice
with Redux-ORM.
I saw you'd responded to a similar question on SO and pointed out that ORM provides its own immutability solution and so you don't get the benefit that Immer provides through use of createSlice
.
Could I ask, would you still use ORM if you were to rewrite the series with the Minimek example?
For context, I'm starting out on a project that has relational data and a requirement for editing 'draft data', so I'm somewhat hesitant to deviate from the great example you set with Minimek ๐
from marks-dev-blog-comments.
I've given a few days careful consideration to my data, its relations and how I will use it. I'm getting the impression that it isn't sufficiently complex to benefit from using Redux-ORM. I found myself really wanting to use it, but my data is quite straight-forward and I'm dealing with only one-to-many relations with nesting of 3/4 levels. I will be normalizing the data, but something I still haven't been able to answer for myself is the question:
"How flat should my state be?"
It maybe misinterpretation, but I feel like any nesting is bad and flat is better.
To give a concrete example, I have a model which represents a multiple choice question. The model has a child array of items which represent the options that each question will present to the user. Each item has a string and a boolean (indicating whether the option represents a correct response) plus potentially some other minor properties. I wanted to normalize the array of items and set it up in the state as a sibling to the question models, e.g:
// state
entities: {
multipleChoiceQuestions: {byId, allIds},
multipleChoiceQuestionItems: {byId, allIds}
}
// example question
{
id: 'cuid1',
title: '...',
items: ['cuid2', 'cuid3', ...]
}
// example item
{
id: 'cuid2',
text: '...',
shouldBeSelected: true
}
However, the items will only be referenced in one place (the parent question), so I wondered:
"Is there any need to normalize or can I just leave the items as an array nested within the question?"
I appreciate your time and assistance greatly.
from marks-dev-blog-comments.
To some extent it's really up to you :) Which I realize is a cop-out answer, but it is very much dependent on your own application's data structures and needs.
To some extent keeping nested data around is less of a pain point or anti-pattern now that RTK makes it a lot easier to update that nested state with "mutating" syntax.
Generally, consider where that data needs to be accessed and how you need to go about updating it.
from marks-dev-blog-comments.
Related Issues (20)
- How Web Apps Work: AJAX, APIs, and Data Transfer HOT 4
- Blogged Answers: Why React Context is Not a "State Management" Tool (and Why It Doesn't Replace Redux) HOT 31
- Coding Career Advice: Using Git for Version Control Effectively HOT 3
- Presentation: JavaScript for Java Devs HOT 1
- Coding Career Advice: Searching and Evaluating Online Information Efficiently HOT 2
- Presentations: Learn Modern Redux Livestream HOT 1
- Blogged Answers: A Comparison of Redux Batching Techniques HOT 1
- Codebase Conversion: Migrating a MEAN AngularJS app to React, Next.js, and TypeScript HOT 1
- Blogged Answers: React, Redux, and Context Behavior HOT 3
- Idiomatic Redux: Designing the Redux Toolkit Listener Middleware HOT 10
- Presentations: Intro to React, Redux, and TypeScript (2020) HOT 1
- How Web Apps Work: JavaScript and the DOM HOT 4
- Reactathon 2022: The Evolution of Redux Async Logic HOT 4
- Blogged Answers: How I Estimate NPM Package Market Share (and how Redux usage compares to other libraries) HOT 1
- Presentations: Modern Redux with Redux Toolkit
- Blogged Answers: The Evolution of Redux Testing Approaches HOT 1
- Presentations: 2022 Podcasts
- Blogged Answers: My Experience Modernizing Packages to ESM HOT 10
- Practical Redux, Part 7: Form Change Handling, Data Editing, and Feature Reducers HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marks-dev-blog-comments.