본문으로 건너뛰기
Skillpedia
웹사이트 및 UI (프런트엔드)40k · #7388

react18-string-refs

하는 일

이 도구는 오래된 React 코드를 최신 버전에 맞게 업데이트하도록 돕습니다. 텍스트 참조(예: ref='myInput')를 더 현대적인 형식(React.createRef())으로 바꿔, 코드가 올바르게 작동하도록 합니다.

사용하는 경우

  • ✓오래된 React 프로젝트를 최신 버전으로 업데이트할 때.
  • ✓React 코드에서 '문자열 ref'에 대한 경고가 보일 때.
  • ✓코드의 참조를 직접 다시 쓰기 전에.

스킬 링크

https://github.com/github/awesome-copilot/blob/main/skills/react18-string-refs/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/react18-string-refs/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“React에서 '문자열 ref'를 최신 형식으로 어떻게 업데이트하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

도구는 React 코드에서 텍스트 참조를 쓰는 곳을 찾습니다. 그다음 현재 React 버전에서 올바른 방식인 React.createRef()로 바꾸는 정확한 패턴을 보여 줍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

React 18 String Refs Migration

String refs (ref="myInput" + this.refs.myInput) were deprecated in React 16.3, warn in React 18.3.1, and are removed in React 19.

Quick Pattern Map

Pattern Reference
Single ref on a DOM element → patterns.md#single-ref
Multiple refs in one component → patterns.md#multiple-refs
Refs in a list / dynamic refs → patterns.md#list-refs
Callback refs (alternative approach) → patterns.md#callback-refs
Ref passed to a child component → patterns.md#forwarded-refs

Scan Command

# Find all string ref assignments in JSX
grep -rn 'ref="' src/ --include="*.js" --include="*.jsx" | grep -v "\.test\."

# Find all this.refs accessors
grep -rn "this\.refs\." src/ --include="*.js" --include="*.jsx" | grep -v "\.test\."

Both should be migrated together - find the ref="name" and the this.refs.name accesses for each component as a pair.

The Migration Rule

Every string ref migrates to React.createRef():

  1. Add refName = React.createRef(); as a class field (or in constructor)
  2. Replace ref="refName" → ref={this.refName} in JSX
  3. Replace this.refs.refName → this.refName.current everywhere

Read references/patterns.md for the full before/after for each case.

자주 묻는 질문

'문자열 ref'는 무엇인가요?

React에서 텍스트 이름으로 요소를 참조하는 오래된 방식입니다. 예를 들어 ref='myInput'처럼 씁니다. 이 방식은 더 안전하고 현대적인 방식으로 대체되었습니다.

왜 업데이트해야 하나요?

'문자열 ref'는 더 이상 권장되지 않으며, 미래의 React 버전에서 제거될 예정입니다. 업데이트하면 코드가 계속 작동하고 새 버전과 호환됩니다.

React.createRef()는 무엇인가요?

클래스 컴포넌트에서 요소에 대한 참조를 만드는 권장되는 최신 방식입니다. 더 안전하고 명확합니다.

상세 정보

작성자의 원본 설명

Provides exact migration patterns for React string refs (ref="name" + this.refs.name) to React.createRef() in class components. Use this skill whenever migrating string ref usage - including single element refs, multiple refs in a component, refs in lists, callback refs, and refs passed to child components. Always use this skill before writing any ref migration code - the multiple-refs-in-list pat

repo: github/awesome-copilot

인기도

GitHub 스타
40k
순위
#7388
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬