Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: React version of M3TextField #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: React version of M3TextField #3

wants to merge 1 commit into from

Conversation

Manblax
Copy link

@Manblax Manblax commented Jun 21, 2024

No description provided.

Copy link
Contributor

@cmath10 cmath10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом бы еще пройтись по вызовам React.* и импортировать вещи отдельно. Еще было бы неплохо дополнить storybook, думаю аналогичную доку пока сделать, как в m3-vue рабочем пространстве.

@@ -0,0 +1,149 @@
import React, { useState, useEffect, useRef, HTMLAttributes } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут бы разделить импорт типов и импорт хуков. Еще стоит убрать импорт React, лучше импортировать FC отдельно, чтобы при сборке лучше работал treeshaking

const [focused, setFocused] = useState(false);
const inputElement = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);

const onInput = (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут надо бы использовать хук useCallback, иначе при перерисовке будет заново создаваться. Еще надо бы отдельно импортировать тип ChangeEvent. Аналогично для остальных обработчиков

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants