mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2025-12-19 17:58:43 -05:00
fix: instead add emitter in Cell (#1718)
* fix: instead add emitter in Cell * chore: better state handling Co-authored-by: Tobias Linsefors <T-Wizard@users.noreply.github.com> * chore: createEmitter properly --------- Co-authored-by: Tobias Linsefors <T-Wizard@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/* eslint-disable react/jsx-props-no-spreading */
|
||||
import React, { forwardRef, useImperativeHandle, useEffect, useState, useContext, useReducer, useRef } from 'react';
|
||||
import EventEmitter from 'node-event-emitter';
|
||||
|
||||
import { Grid, Paper } from '@mui/material';
|
||||
import { useTheme } from '@nebula.js/ui/theme';
|
||||
@@ -312,6 +313,10 @@ const loadType = async ({
|
||||
}
|
||||
};
|
||||
|
||||
function createEmitter() {
|
||||
return new EventEmitter();
|
||||
}
|
||||
|
||||
const Cell = forwardRef(
|
||||
(
|
||||
{
|
||||
@@ -337,6 +342,7 @@ const Cell = forwardRef(
|
||||
keyboardNavigation,
|
||||
disableCellPadding = false,
|
||||
} = useContext(InstanceContext);
|
||||
const [internalEmitter] = useState(emitter || createEmitter);
|
||||
const theme = useTheme();
|
||||
const [cellRef, cellRect, cellNode] = useRect();
|
||||
const [state, dispatch] = useReducer(contentReducer, initialState(initialError));
|
||||
@@ -436,7 +442,7 @@ const Cell = forwardRef(
|
||||
selections,
|
||||
nebbie,
|
||||
focusHandler: focusHandler.current,
|
||||
emitter,
|
||||
emitter: internalEmitter,
|
||||
onMount,
|
||||
navigation,
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { useEffect, useState, useContext, useMemo, forwardRef, useImperativeHandle, useRef } from 'react';
|
||||
import EventEmitter from 'node-event-emitter';
|
||||
import useLayout from '../hooks/useLayout';
|
||||
import getObject from '../object/get-object';
|
||||
import Cell from './Cell';
|
||||
@@ -28,8 +27,6 @@ function getCellRenderer(cell, halo, initialSnOptions, initialSnPlugins, initial
|
||||
style.padding = '4px';
|
||||
}
|
||||
|
||||
const emitter = new EventEmitter();
|
||||
|
||||
return (
|
||||
<div style={style} key={cell.model.id}>
|
||||
<Cell
|
||||
@@ -41,7 +38,6 @@ function getCellRenderer(cell, halo, initialSnOptions, initialSnPlugins, initial
|
||||
initialSnPlugins={initialSnPlugins}
|
||||
initialError={initialError}
|
||||
onMount={onMount}
|
||||
emitter={emitter}
|
||||
navigation={navigation}
|
||||
onError={onError}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user