Comments (5)
By the way, as I said I am not that hot on React development but I found that I needed to change the webpack.SourceMapDevToolPlugin
to set noSources
to false when debugging in order to get half-decent debugging experience. Is there a better way to manage this?
from covid19_scenarios.
Ahah! So it seems that the first time draw()
is called we have d3ref.current
is null
, which causes an error and so the effect is not run again. Adding a guard against this and adding d3ref.current
as a dependency for the effect seems to solve the problem:
function draw({ data, width, height, onDataChange, d3ref }: DrawParams) {
if (d3ref.current === null) {
return
}
...
useEffect(() => draw({ data, onDataChange, width, height, d3ref }), [data, width, height, d3ref.current])
from covid19_scenarios.
I am not that up with React but I had a little play and it seems to me that this component only needs to re-render the graph if the time series changes, which is defined by the data
property, or when the size of the graph changes, which is defined by the width
and height
properties. Yes?
So I changed
to be: useEffect(() => draw({ data, onDataChange, width, height, d3ref }), [data, width, height])
and that seems to solve the problem. Now the graph only re-renders if the start and end dates change, or the number of points changes (this triggers a recalculation of data
) or the window is resized (this updates width
and height
).
Also previous to this the graph is re-rendering on just about every event, not only focus events but all other kinds of events that are not related to this graph.
Happy to create a PR for this if it is agreed that this is the correct solution...
from covid19_scenarios.
Oops! Of course now the graph is not rendered correctly at application start up... :-(
from covid19_scenarios.
Regarding source maps: #94 (comment)
from covid19_scenarios.
Related Issues (20)
- Option for adding Google Mobility data as an additive mitigation NPI HOT 3
- Option for correcting observed case counts using test positivity data and/or recorded deaths HOT 3
- Simulation plot changes every time refresh is pressed. HOT 1
- 🇧🇷 Brazil case data is incorrect HOT 7
- Step-by-step guide for parameter adjustment HOT 5
- Port to Next.js HOT 1
- Split app data per region and load on demand
- Don't bunde the data HOT 7
- weekly cases(data) vs weekly death (model) HOT 7
- Document, improve schema modification workflow
- Second wave
- Seroprevalence
- I want to contribute for Spanish translation HOT 4
- Missing Patients in hospital (data) in the results HOT 5
- Not all strings are translated
- API HOT 4
- Include effect of vaccination HOT 3
- Outcomes Summary Table
- Missing (And wrong) data shown before 08-16-2020 HOT 3
- [Security] Workflow eslint.yml is using vulnerable action reviewdog/action-eslint
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 covid19_scenarios.