반응형

    input + input {
      margin-top: 10px;
    }

반응형
반응형

input is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`

반응형
반응형

https://codesandbox.io/s/explorer-l44v98?file=/index.js

 

Explorer - CodeSandbox

Explorer by fir0j using antd, react, react-dom, react-icons, react-scripts, styled-components

codesandbox.io

 

위 소스는 자식이 2개 이상 있으면 2개가 한꺼번에 오픈되는 에러 있음, 아래는 에러 수정한 버젼

import React, { Fragment, useEffect, useState } from "react";
import { IoMdArrowDropright } from "react-icons/io";
import { MdArrowDropDown } from "react-icons/md";
import styled from "styled-components";

const SelectParent = styled.div`
  padding: 7px 7px;
  background-color: darkblue;
  width: max-content;
  border-radius: 4px;
  margin-top: 4px;
  font-weight: bolder;
  color: white;
  cursor: pointer;
`;

const Selectname = styled.div`
  margin-top: 5px;
  padding: 7px 7px;
  width: fit-content;
  border-radius: 4px;
  cursor: default;
  color: darkblue;
  :hover {
    background-color: #bdbaba3c;
  }
`;

const Explorer = ({ parent = [], onParentClick, onNameClick /*expandOnHover = false*/ }) => {
  const [newData, setNewData] = useState([]);

  useEffect(() => {
    setNewData(parent.map((n) => ({ ...n, expand: false })));
  }, [parent]);

  const handleClickOnParent = (e, data) => {
    e.stopPropagation();
    if (onParentClick && onParentClick instanceof Function) onParentClick(data);

    const clickIdx = newData.findIndex((n) => data.name === n.name);
    const clickItem = newData.find((n) => data.name === n.name);

    setNewData([...newData.slice(0, clickIdx), { ...clickItem, expand: !clickItem.expand }, ...newData.slice(clickIdx + 1, newData.length)]);
  };

  const handleClickOnName = (e, data) => {
    e.stopPropagation();

    if (onNameClick && onNameClick instanceof Function) onNameClick(data);
  };

  return (
    <>
      {newData.map((item) => (
        <Fragment key={item.name}>
          {item.children && item.children.length ? (
            <Fragment /*key={index}*/>
              <SelectParent /*onMouseOver={() => (expandOnHover ? setExpand(true) : {})}*/ onClick={(e) => handleClickOnParent(e, item)}>
                {item.name} <span>{!item.expand ? <IoMdArrowDropright /> : <MdArrowDropDown />} </span>
              </SelectParent>

              {item.expand ? (
                <div style={{ paddingLeft: "1.5rem" }}>
                  <Explorer parent={item.children} onParentClick={onParentClick} onNameClick={onNameClick} /*expandOnHover={expandOnHover}*/ />
                </div>
              ) : null}
            </Fragment>
          ) : (
            <Selectname onClick={(e) => handleClickOnName(e, item)}>{item.name}</Selectname>
          )}
        </Fragment>
      ))}
    </>
  );
};

export default Explorer;
반응형
반응형

rowspan 사용예제

<table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
    <th>Savings for holiday!</th>
  </tr>
  <tr>
    <td rowspan="2">January</td>
    <td>1</td>
    <td>2</td>
  </tr>
  <tr>
    <td>3</td>
    <td>4</td>
  </tr>
  <tr>
    <td rowspan="2">February</td>
    <td>11</td>
    <td>22</td>
  </tr>
  <tr>
    <td>33</td>
    <td>44</td>
  </tr>
</table>

 

https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_td_rowspan

 

https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_td_colspan

반응형
반응형
.popupModal [class="image"] {
    text-align: center;
  }
반응형
반응형
반응형
반응형

const a = arg||'default' 주로 이렇게 초기화용도로 쓰는데 0, ''도 정상값일 경우는 ??를 쓰면 됨

 

Nullish coalescing operator

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing

 

Logical or operator

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR

 

 

반응형
반응형

style={{width: n.position?.width||'100%'}} 로 구지 안해도 style={{width: n.position?.width}} 만 하면 됨, n.position이 null이면 n.position?.width는 undefined가 되므로

반응형
반응형

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at editorwatchdog.js:179:1
    at async u._initializeEditor (index.js:5:4518)
    at async u.componentDidMount (index.js:5:3736) {phase: 'initialization', willEditorRestart: false}phase: "initialization"willEditorRestart: false[[Prototype]]: Object
(anonymous) @ index.js:5
Promise.catch (async)
_initializeEditor @ index.js:5
await in _initializeEditor (async)
componentDidMount @ index.js:5
commitLayoutEffectOnFiber @ react-dohttp://m.development.js:23349
commitLayoutMountEffects_complete @ react-dohttp://m.development.js:24727
commitLayoutEffects_begin @ react-dohttp://m.development.js:24713
commitLayoutEffects_begin @ react-dohttp://m.development.js:24695
commitLayoutEffects @ react-dohttp://m.development.js:24651
commitRootImpl @ react-dohttp://m.development.js:26862
commitRoot @ react-dohttp://m.development.js:26721
performSyncWorkOnRoot @ react-dohttp://m.development.js:26156
flushSyncCallbacks @ react-dohttp://m.development.js:12042
(anonymous) @ react-dohttp://m.development.js:25690
Show 13 more frames
Show less

 

 

Cannot read properties of null (reading 'model') TypeError: Cannot read properties of null (reading 'model') at http://localhost:3000/app.2d361dd0ad882d7da2b1.min.js:289211:20

 

 

 

https://github.com/ckeditor/ckeditor5-react/issues/442

 

TypeError: Cannot read properties of null (reading 'model') · Issue #442 · ckeditor/ckeditor5-react

I'm trying to implement CKEditor 5 to my Nextjs project using this guide: https://ckeditor.com/docs/ckeditor5/latest/installation/integrations/next-js.html However when I try to run the webpage sho...

github.com

 

반응형
반응형

import { parse } from "node-html-parser";
dangerouslySetInnerHTML={{ __html: parse(n.content)?.toString() }} 원래 소스에는 parse를 적용했는데 안해도 나왔음

반응형

+ Recent posts