Skip to content

Bug: Why is ref.current null when I get it in the useFetch callback? #26146

@catchex

Description

@catchex

React version: "react": "^17.0.2", "react-dom": "^17.0.2",

const tagsId = tagInputRef.current!.getTags().map(t => t.id); // It works OK! And it's called in click handler
setSuggestions([]);
loadSuggestions(`/schemas/${schema!._key}/suggestions?text=${text}`)
    .then((suggestions) => {
        const tagsId = tagInputRef.current!.getTags().map(t => t.id);   // The current is NULL ?????
        let rawSuggestions = suggestions.map(
            (suggestion) => new SuggestionKeyword(schema!._key!, suggestion));
        rawSuggestions = rawSuggestions?.filter(s => !tagsId.includes(s.id)) || []
        setSuggestions(rawSuggestions);
    })

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: StaleAutomatically closed due to inactivityStatus: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions