binbot-charts 0.2.34 → 0.2.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,6 +15,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
|
|
16
16
|
var _useImmer = require("use-immer");
|
|
17
17
|
|
|
18
|
+
var _hooks = require("./hooks");
|
|
19
|
+
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
21
|
|
|
20
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -36,6 +38,9 @@ function TVChartContainer(_ref) {
|
|
|
36
38
|
const [chartOrderLines, setChartOrderLines] = (0, _useImmer.useImmer)([]);
|
|
37
39
|
const [widgetState, setWidgetState] = (0, _useImmer.useImmer)(null);
|
|
38
40
|
const [symbolState] = (0, _react.useState)(null);
|
|
41
|
+
const prevStates = (0, _hooks.usePrevious)({
|
|
42
|
+
timescaleMarks: timescaleMarks
|
|
43
|
+
});
|
|
39
44
|
(0, _react.useEffect)(() => {
|
|
40
45
|
if (!widgetState) {
|
|
41
46
|
initializeChart();
|
|
@@ -48,9 +53,14 @@ function TVChartContainer(_ref) {
|
|
|
48
53
|
if (widgetState && symbol !== symbolState) {
|
|
49
54
|
widgetState.setSymbol(symbol, interval);
|
|
50
55
|
}
|
|
51
|
-
|
|
56
|
+
|
|
57
|
+
if (prevStates && prevStates.timescaleMarks !== timescaleMarks) {
|
|
58
|
+
initializeChart();
|
|
59
|
+
}
|
|
60
|
+
}, [orderLines, timescaleMarks]);
|
|
52
61
|
|
|
53
62
|
const initializeChart = () => {
|
|
63
|
+
console.log(timescaleMarks);
|
|
54
64
|
const widgetOptions = {
|
|
55
65
|
symbol: symbol,
|
|
56
66
|
datafeed: new _datafeed.default(timescaleMarks),
|
|
@@ -110,7 +120,7 @@ function TVChartContainer(_ref) {
|
|
|
110
120
|
}
|
|
111
121
|
};
|
|
112
122
|
|
|
113
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null,
|
|
123
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
114
124
|
ref: containerRef,
|
|
115
125
|
style: {
|
|
116
126
|
height: height
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePrevious = usePrevious;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
function usePrevious(value) {
|
|
11
|
+
const ref = (0, _react.useRef)();
|
|
12
|
+
(0, _react.useEffect)(() => {
|
|
13
|
+
ref.current = value;
|
|
14
|
+
});
|
|
15
|
+
return ref.current;
|
|
16
|
+
}
|
package/package.json
CHANGED