Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update: Valid React-component names used for useDescendants
  • Loading branch information
KenAJoh committed Oct 17, 2024
commit 84e9149a8ae171946cfe6ac104541700b0c46d59
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* - We should add "plugin:react/jsx-runtime", but not sure if this will cause problems for projects not using the new JSX transform
* - Consider adding the rule "id-length"
*/

/**
* V9 migration WIP
* -
*/
module.exports = {
env: {
browser: true,
Expand Down
10 changes: 5 additions & 5 deletions @navikt/core/react/src/util/hooks/descendants/useDescendant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function createDescendantContext<
K extends Record<string, any> = object,
>() {
const [DescendantsContextProvider, useDescendantsContext] = createContext<
ReturnType<typeof _useDescendants>
ReturnType<typeof UseDescendants>
>({
name: "DescendantsProvider",
errorMessage:
Expand All @@ -38,7 +38,7 @@ export function createDescendantContext<
* - ref callback to register the descendant
* - Its enabled index compared to other enabled descendants
*/
function _useDescendant(options?: DescendantOptions<K>) {
function UseDescendant(options?: DescendantOptions<K>) {
const descendants = useDescendantsContext();
const [index, setIndex] = useState(-1);
const ref = useRef<T>(null);
Expand Down Expand Up @@ -74,7 +74,7 @@ export function createDescendantContext<
* @internal
* Initializing DescendantsManager
*/
function _useDescendants() {
function UseDescendants() {
const descendants = useRef(new DescendantsManager<T, K>()).current;

return descendants;
Expand All @@ -86,8 +86,8 @@ export function createDescendantContext<
// call this when you need to read from context
useDescendantsContext,
// descendants state information, to be called and passed to `ContextProvider`
_useDescendants,
UseDescendants,
// descendant index information
_useDescendant,
UseDescendant,
] as const;
}