Giter Site home page Giter Site logo

baguni's Introduction

Hi 👋, I'm Igor Hwang

Multilingual problem-solver from Korea

  • 🔭 I’m currently working on baguni

  • 🌱 I’m currently learning System Architecture

  • 💬 Ask me about panini, fastapi

  • 📫 Reach me at [email protected]

Connect with me:

khvanigor

Languages and Tools:

dart docker figma firebase flutter git grafana ifttt javascript linux mongodb mysql nextjs nginx postgresql postman python react redis tailwind typescript

i2gor87

baguni's People

Contributors

i2gor87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

baguni's Issues

vas3k review

👋

const reRender = () => set({});

React hook FAQ советует использовать следующий подход:

const [, reRender] = useReducer(x => x + 1, 0);

baguni/src/index.js

Lines 30 to 36 in bbab8bb

const reRender = () => set({});
useEffect(() => {
bState.joinReRender(reRender);
return () => {
bState.cancelReRender(reRender);
};
}, [bState]);

Функция reRender создаётся новая на каждый рендер, а хук useEffect отрабатывает только на изменение bState, в результате чего в cancelReRender попадает другая функция reRender, чем была добавлена в joinReRender, то есть старые функции не удаляются, что вызывает утечку памяти. Если заюзать подход из п.1, проблема должна уйти, т.к. функция будет стабильная.

baguni/src/index.js

Lines 37 to 39 in bbab8bb

function setState(newState) {
bState.set(newState);
}

Функция setState создаётся новая на каждый рендер, это поведение не аналогично хуку useState, где функция стабильная. Это может вызвать проблемы с рендерами, если пользователь не будет учитывать этот момент.

return Object.freeze(Object.create(prototype));

Создание объекта через Object.freeze(Object.create(...)) выглядит как ненужное переусложнение на мой взгляд. Это выглядит как попытка защитить объект от изменений вручную, но такая «защита» без проблем обходится
image

PS
Я не пробовал код в работе, это просто визуальное ревью.
Замечу, что написание стейт менеджера это очень сложная задача, гораздо сложнее, чем кажется на первый взгляд.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.