ruilisi/fortune-sheet

Why my updateSheet method not works?

khj0426 opened this issue · 2 comments

Describe the bug
A clear and concise description of what the bug is.

TypeError: Cannot assign to read only property 'data' of object '#'

I get this errror when i use update sheet method.
i tried to use immer to maintain object deep, but i got a same error.

why my error begin and how cam i resolve it?

<Workbook
  data={scheduleData?.data as any}
  ref={ref}
  onChange={(data) => {
    if (ref.current) {
      const updatedData = produce(
        scheduleData.data,
        (draft) => {
          data.forEach((newSheet, index) => {
            draft[index] = {
              ...draft[index], // 기존 데이터 유지
              ...newSheet, // 새로운 데이터로 업데이트
            };
          });
        }
      );

      ref.current.updateSheet(updatedData); // 업데이트 호출
    }
  }}
  lang={lng}
  config={{
    cellTextOverflow: "visible",
    cellAutoWrap: true,
    readOnly: true,
  }}
/>

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

maybe this solution will solve your problem click

can you please describe what is he goal here? might be another way of doing it.