
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-gojs
Advanced tools
:warning: react-gojs is no longer under active development. Now, Northwoods provides an official React integration for GoJS: https://github.com/NorthwoodsSoftware/gojs-react. I will not add new features to this lib, only bug fixes. The migration to the official library is pretty easy. I migrated my example here.
react-gojs is a GoJS React integration.
Install it from npm. It has peer dependencies of react and react-dom, which will have to be installed as well.
npm install --save react-gojs
or:
yarn add react-gojs
Import GojsDiagram in your React component:
import GojsDiagram from 'react-gojs';
To create a GoJS diagram, just use the GojsDiagram React component:
<GojsDiagram
diagramId="myDiagramDiv"
model={this.props.model}
createDiagram={this.createDiagram}
className="myDiagram"
onModelChange={this.modelChangedhandler}
updateDiagramProps={this.updateDiagramProps}
/>
GojsDiagram is a generic React component which is responsible for rendering and updating (when the model changes) the diagram. The render step is based on the model and the go.Diagram object provided as props. It acts as a go.Diagram wrapper.
GojsDiagram props:
Model type: DiagramModel<N extends BaseNodeModel, L extends LinkModel>
Example (Typescript / Javascript):
const model = {
nodeDataArray: [
{ key: 'Alpha', color: 'lightblue' },
{ key: 'Beta', color: 'orange' },
{ key: 'Gamma', color: 'lightgreen' },
{ key: 'Delta', color: 'pink' },
{ key: 'Omega', color: 'grey' }
],
linkDataArray: [
{ from: 'Alpha', to: 'Beta' },
{ from: 'Alpha', to: 'Gamma' },
{ from: 'Beta', to: 'Delta' },
{ from: 'Gamma', to: 'Omega' }
]
};
Typescript example:
const createDiagram = (diagramId: string): Diagram => {
const $ = go.GraphObject.make;
const myDiagram: Diagram = $(go.Diagram, diagramId, {
initialContentAlignment: go.Spot.LeftCenter
});
myDiagram.nodeTemplate = $(
go.Node,
'Auto',
$(go.Shape, 'RoundedRectangle', { strokeWidth: 0 }, new go.Binding('fill', 'color')),
$(go.TextBlock, { margin: 8 }, new go.Binding('text', 'key'))
);
return myDiagram;
};
Javascript (ES6) example:
const createDiagram = diagramId => {
const $ = go.GraphObject.make;
const myDiagram = $(go.Diagram, diagramId, {
initialContentAlignment: go.Spot.LeftCenter
});
myDiagram.nodeTemplate = $(
go.Node,
'Auto',
$(go.Shape, 'RoundedRectangle', { strokeWidth: 0 }, new go.Binding('fill', 'color')),
$(go.TextBlock, { margin: 8 }, new go.Binding('text', 'key'))
);
return myDiagram;
};
Example:
.myDiagram {
width: 70%;
height: 400px;
}
For example, in a Redux environment, the diagram model should be immutable (and stored in the redux store). The onModelChange handler can dispatch actions to update the model.
Example 1:
const updateDiagramProps = (myDiagram: Diagram): void => {
myDiagram.layout = go.GraphObject.make(go.LayeredDigraphLayout, { direction: 90 });
// User can add more properties here.
};
Example 2:
const updateDiagramProps = (myDiagram: Diagram): void => {
// Empty method.
};
Typescript: You can find a react / redux / react-gojs example + live demo here.
Javascript (ES6): You can find a react / react-gojs example + live demo here.
yarn install
yarn build
yarn test
git checkout -b my-new-featureyarn lintgit commit -am 'Add some feature'git push origin my-new-featureFAQs
GoJS React integration
The npm package react-gojs receives a total of 300 weekly downloads. As such, react-gojs popularity was classified as not popular.
We found that react-gojs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.