Загрузка данных


useEffect(() => {
  const fieldValue = getMasterInstrumentFromPublicContext();

  if (!fieldValue && widget?.master) {
    const defaultInstrument = instruments.find(
      (instrument) => instrument.issKey === DEFAULT_SYMBOL,
    );

    setCurrInstrument({
      symbolId: DEFAULT_SYMBOL,
      symbol: defaultInstrument?.symbol ?? undefined,
      symbolName: defaultInstrument?.displayName ?? undefined,
    });

    return;
  }

  const instrument = instruments.find(
    (item) => item.issKey === fieldValue,
  );

  if (!instrument?.issKey) {
    return;
  }

  setCurrInstrument({
    symbolId: instrument.issKey,
    symbol: instrument.symbol ?? undefined,
    symbolName: instrument.displayName ?? undefined,
  });
  // eslint-disable-next-line react-hooks/exhaustive-deps -- Посмотреть этот момент.
}, [
  publicContext,
  instruments,
  widget?.externalProperties,
  setCurrInstrument,
]);