{"size": 476, "ext": "js", "max_stars_repo_path": "prototypes/vizhub-v2-false-start/packages/frontend/src/contexts/viz/useVizStub.js", "max_stars_repo_name": "pravalliyaram/vizhub", "max_stars_repo_stars_event_min_datetime": "2021-12-10T20:50:43.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-23T13:10:49.000Z", "max_issues_repo_path": "prototypes/vizhub-v2-false-start/packages/frontend/src/contexts/viz/useVizStub.js", "max_issues_repo_name": "pravalliyaram/vizhub", "max_issues_repo_issues_event_min_datetime": "2021-12-09T21:24:00.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-27T17:32:47.000Z", "max_forks_repo_path": "prototypes/vizhub-v2-false-start/packages/frontend/src/contexts/viz/useVizStub.js", "max_forks_repo_name": "pravalliyaram/vizhub", "max_forks_repo_forks_event_min_datetime": "2021-12-13T14:12:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-29T02:04:45.000Z"}
{"max_stars_count": 29, "max_issues_count": 7, "max_forks_count": 20, "avg_line_length": 29.75, "max_line_length": 67, "alphanum_fraction": 0.6932773109}
import { useState } from 'react';
import { type as json0 } from 'ot-json0';
const clone = obj => JSON.parse(JSON.stringify(obj));

export const useVizStub = (vizId, vizSnapshots) => {
  const [vizData, setVizData] = useState(vizSnapshots[vizId].data);

  const submitVizOp = op => {
    setVizData(clone(json0.apply(vizData, op)));
  };

  // Intentionally different from the ShareDB API,
  // to decouple application logic from ShareDB.
  return { vizData, submitVizOp };
};
