Chart behaves identical whether it's dumb (no state) or whether it has state
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 文件
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript, react
研究方向
該 issue 沒有指出任何 repository 檔案或測試;請先定位文件中關於 “dumb” 元件的段落,並將其與兩個 React 範例進行比較。重現回報中的 pan、zoom、rerender 和 resize 行為,然後在確認預期行為後,釐清該警告或記錄預期的區別。
由索引模型根據 Issue 內容生成。
描述
The docs state that: This is a "dumb" component that doesn't merge its internal state with any updates. This means that if a user interacts with the plot, by zooming or panning for example, any subsequent re-renders will lose this information unless it is captured and upstreamed via the onUpdate callback prop.
But the following two pieces of code behave identically:
- without state:
function StackedAreaChart({) {
const layout = {
showlegend: true,
legend: {
x: 0,
y: -0.15,
orientation: "h",
traceorder: "normal",
yanchor: "top",
},
autosize: true,
margin: { pad: 10, b: 10, l: 40, r: 40, t: 80 },
};
const plotData = [...someData]
return (
<div style={{ height: 650 }} data-cy="stacked-area-chart">
<Plot
data={plotData}
layout={layout}
style={{ width: "100%", height: "100%" }}
useResizeHandler
/>
</div>
);
}
export default StackedAreaChart;
- and with state:
function StackedAreaChart() {
const [chart, setChart] = useState({
data: [],
layout: {
showlegend: true,
legend: {
x: 0,
y: -0.15,
orientation: "h",
traceorder: "normal",
yanchor: "top",
},
xaxis: { range: [2000, 2019] },
autosize: true,
margin: { pad: 10, b: 10, l: 40, r: 40, t: 80 },
},
config: { responsive: true },
});
useEffect(() => {
const plotData = [...someData];
setChart((prevState) => ({
...prevState,
data: [...plotData],
}));
}, [setChart, data]);
return (
<div style={{ height: 650 }} data-cy="stacked-area-chart">
<Plot
data={chart.data}
layout={chart.layout}
config={chart.config}
style={{ width: "100%", height: "100%" }}
useResizeHandler
/>
</div>
);
}
export default StackedAreaChart;
I can pan and zoom and then double click to return to its initial state on both codes. I can also modify the viewport width, making the chart to resize, while zoomed in and the chart still behaves perfectly.
I don't understand the warning in the documentation.
Am I doing something wrong ?
- 主要語言
- JavaScript
- 星號
- 1.1k
- 分支
- 138
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
plotly/react-plotly.js 的其他 Issue
-
P3 plotly-internal size: 1 task
難度 3/5 1-2 天 新手友好度 45/100
plotly/react-plotly.js#386 ·
-
難度 4/5 3-5 天 新手友好度 48/100
plotly/react-plotly.js#358 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 35/100
plotly/react-plotly.js#354 ·
-
難度 3/5 1-2 天 新手友好度 30/100
plotly/react-plotly.js#353 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 35/100
plotly/react-plotly.js#352 · 1 則留言 ·
查看 plotly/react-plotly.js 的全部 Issue
相似的 Issue
-
bug confirmed js v6
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
BUG
難度 1/5 1-3 小時 新手友好度 90/100
linuxmint/cinnamon-spices-applets#9223 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
nopSolutions/nopCommerce#8440 ·
維護者通常 1 天內回覆
-
follow-up
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆