
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
iot-react-grid
Advanced tools
An implementation of the react-grid-layout that accepts different widgets to displayed inside the grid items and enables widget communication at the grid level.
The required props to initlize the grid are its initial dimensions and an array containing the widgets that may be added to the grid. The Grid component must be wrapped in a which with the controller state (its redux store), should be imported and passed as a prop as such:
<Provider store={store}>
<ReactGrid
onChange={(elements, layout, controller, state) => {console.log('UPDATE OCCURRED', state)}}
initState={{
dashboard: [
{
element: {id: 'Widget1', gridId: '0'},
layout: {i: '0', x: 0, y: 0, w: 11, h: 4}
},
{
element: {id: 'Widget2', gridId: '1'},
layout: {i: '1', x: 0, y: 4, w: 6, h: 4}
},
],
controller: {
abc: 'xxx'
},
}}
components={[ReactGridViewWidget1, ReactGridViewWidget2]}
width={1724}
height={800}
rowHeight={50}
isDroppable={true}/>
</Provider>
Its optional props extended react-grid-layout props. Some of the more relevant include:
function createItem(el: GridComp, removeFunction: (i: string | undefined) => void, _controller: GridControllerObject, state: {[key: string]: any}, index: number){
return (
<div id={'widget-'+ el.id + index} key={el.gridId} className={"d-flex flex-column rounded border border-secondary-subtle bg-white overflow-hidden"}>
<div className={"d-flex flex-row w-100"}>
<div className={"bg-secondary flex-inline-flex mr-auto drag-handle"}
style={{borderTopLeftRadius: '5px', borderBottomRightRadius: '5px', cursor: 'pointer'}}>
{el.title}
</div>
<div className={"d-inline-flex ml-auto align-items-center"} style={{cursor: 'pointer'}}>
<GearWide width={20} fill={"grey"} onClick={() => {el?.optionsMenu? controller?.updateWidgetOptions(gridElements, setGridElements, layout, setLayout, index, el?.optionsMenu(gridElements[index])) : null}}/>
<XCircle width={20} fill={"red"} onClick={() => {removeFunction(el.gridId)}}/>
</div>
</div>
<div className={"d-flex overflow-auto h-100 w-100 overflow-auto"}>
{el?.render? el.render(state) : null}
</div>
</div>
)
}
Widgets are functions that receive the controller as a prop so they can interact with the grid. Example:
function ReactGridViewWidget1(controller: GridControllerObject): GridComp{
const options = {
title: 'React Grid Widget',
Icon: '',
id: 'Widget1',
minW:3,
isBounded: true,
publishesTo: ['shipData'],
subscribesTo: [],
}
React.useEffect(() => {
console.log('WIDGET 1 USEEFFECT')
}, [])
function optionsMenu(element: GridComp){
return {...options, title: 'xxxx'}
}
function onInit(state: ControllerState){
console.log('Widget 1 init', state)
}
function render(state: ControllerState){
return <div className={"d-flex flex-row w-100 h-100 justify-content-center align-items-center"} onClick={() => {controller?.publishInfo(options.publishesTo[0], ['yyy', '1111'])}}>React Widget1 {state.shipData}</div>
}
function onRemove(state: ControllerState){
console.log('Widget 1 removed', state);
}
return {render, onInit, onRemove, optionsMenu,...options}
}
Each widget should inclue a render method that accepts a controller state as an argument. This method will be called whenever there is a layout change or state change and it should return a JSX.Element to display inside the grid item.
Optinal methods such as onInit and onRemove may be added to for the widget to do something whenever it is added to the grid or removed from it. An optional optionsMenu functional may be added allow for editing of its options. Its options object declares its default settings these include:
The controller provides a set of functions to interact with the grid an other utilities. Some of the most important are:
export default function ReactGridViewWidget1(controller: GridControllerObject): GridComp{
const options = WidgetConfiguration()
let currentState: {[key: string]: any};
React.useEffect(() => {
console.log('WIDGET 1 USEEFFECT')
}, [])
function optionsMenu(element: GridComp){
return {...options, title: 'xxxx'}
}
function onInit(state: ControllerState){
console.log('Widget 1 init', state)
}
function render(state: ControllerState){
let prevState = currentState;
currentState = state;
if(controller?.compareStateChanges(options.subscribesTo, prevState, currentState).length > 0){
//do something
}
return <div className={"d-flex flex-row w-100 h-100 justify-content-center align-items-center"} onClick={() => {controller?.publishInfo(options.publishesTo[0], ['yyy', '1111'])}}>React Widget1 {state.shipData}</div>
}
function onRemove(state: ControllerState){
console.log('Widget 1 removed', state);
}
return {render, onInit, onRemove, optionsMenu,...options}
}
FAQs
An implementation of the react-grid-layout that accepts different widgets to displayed inside the grid items and enables widget communication at the grid level.
We found that iot-react-grid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.