반응형

문제

해당 라이브러리의 카카오맵을 생성하기위해서는 width, height 를 입력받아야한다. docs 에서 width, height 의 type 이 String, Number 로 작성되어있어 숫자 혹은 숫자와 단위를 포함한 문자열을 입력할 수 있다는 것을 알 수 있다. 하지만, 예상외로 로컬 환경에서 문자열 값이 적용되지 않는 문제를 발견했다.

문제코드

const r = S(() => ({
      width: isFinite(+i.width) ? i.width + "px" : i.width,
      height: isFinite(+i.height) ? i.height + "px" : i.height
}));

해당 코드는 얼핏보면 문자열과 숫자를 모두 입력받는 것을 의도하지만 정작 문자열값이 적용이 되지 않았다.

<KakaoMap
    :width="`${50}vw`"
    :height="`${90}vh`"
    :lat="37.566826"
    :lng="126.9786567"
    @onLoadKakaoMap="onLoadKakaoMap"
/>
  • 추후에 알게 된 것이지만 width, height 값에 문자열을 삽입하려면 위와 같은 작업을 거쳐야 했다. 이러한 설명이 docs에는 준비되어있지않아 애초에 문자열로 받도록 한다면 문제가 없을것이라 판단했다.

멍청 비용 발생

<KakaoMap
    :width="'50vw'"
    :height="'90vh'"
    :lat="37.566826"
    :lng="126.9786567"
    @onLoadKakaoMap="onLoadKakaoMap"
/>
  • 작은 따옴표로 감싸면 된다 ^^;
  • 멍청비용 한시간 발생
반응형
반응형

배경


useEffect 를 이용해 한번만 함수를 처리하게 하려고 했다.
하지만 왜인지 모르게 자꾸 렌더링이 두번씩 되어 함수가 두번 실행이 되었다.

 

해결

https://youngble.tistory.com/175

 

[React] useEffect 2번 실행되는 이유

다음과 같이 useEffect를 사용하여 jQuery메서드 on 으로 해당 요소를 이벤트 등록을 해주었다. 그런데 해당 태그를 눌러 이벤트가 발생하면 2번이 실행돼서 왜이러지? 찾아보니깐 useEffect부분에서 두

youngble.tistory.com

다음 글을 보면 index.js 의 React.StrictMode 때문이라고 한다.

 

import React from 'react';

function ExampleApplication() {
  return (
    <div>
      <Header />
      <React.StrictMode>
        <div>
          <ComponentOne />
          <ComponentTwo />
        </div>
      </React.StrictMode>
      <Footer />
    </div>
  );
}

 

개발모드에서만 작동되는 StrictMode 는 다음과 같은 효과를 준다고한다.

  1. 안전하지 않은 생명주기를 사용하는 컴포넌트 발견
  2. 레거시 문자열 ref 사용에 대한 경고
  3. 권장되지 않는 findDOMNode 사용에 대한 경고
  4. 예상치 못한 부작용 검사
  5. 레거시 context API 검사
  6. Ensuring reusable state

https://ko.legacy.reactjs.org/docs/strict-mode.html

 

Strict 모드 – React

A JavaScript library for building user interfaces

ko.legacy.reactjs.org

문서에 들어가면 더 자세히 볼 수 있다.

 

결론은 index.js React.StrictMode 를 제거하면 한 번만 호출 된다.
반응형
반응형

배경

opencv 를 쓰기 위해 파이썬 코드를 작성해 nodejs 서버에서 실행하고 있었다.

결과

https://github.com/pyinstaller/pyinstaller/issues/2613

 

How to generate an executable on Linux for Windows? · Issue #2613 · pyinstaller/pyinstaller

I'm trying to generate an executable from Linux for Windows. pyinstaller --onefile --windowed montecarlo.py I run this command and get a single executable that works on Linux just fine, I can open ...

github.com

 

하지만 조사결과 그렇게하지 못한다고 한다.

Pyinstaller 메뉴얼을 보면 다음과 같은 글이있다.

PyInstaller is tested against Windows, Mac OS X, and Linux. However, it is not a cross-compiler: to make a Windows app you run PyInstaller in Windows; to make a Linux app you run it in Linux, etc. PyInstaller has been used successfully with AIX, Solaris, and FreeBSD, but is not tested against them.

according to the comments in that answer it appears the ability to cross-compile was removed in 1.5, which was many releases ago. However, the secondary answer mentioning wine is correct -- you can usually create working Windows executables if you run pyinstaller under wine.

And as @xoviat mentioned, pyinstaller is cross-platform -- the compilation program works on Linux, OSX, and Windows. However, the resulting executables are platform specific.

 

한마디로 cross-compiler 가 아니라 불가능하다는 것이다. Wine 을 쓰는걸 추천한고 한다.

 

그리고, pyinstaller 는 사용자의 OS 환경에 맞게 실행파일을 만들어준다. linux 에서 배포를 했으면 조금은 달라졌을까?

왠만하면 언어 하나만을 쓰는걸로 생각하는게 정신건강에 좋을 듯 하다.

반응형

+ Recent posts