MCPcopy Index your code
hub / github.com/atorov/react-hooks-p5js

github.com/atorov/react-hooks-p5js @2.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.2.0 ↗ · + Follow
9 symbols 27 edges 17 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Using React with p5.js

alt application screenshot alt application screenshot

This project demonstrates how to combine React (including the latest features such as hooks and context) and p5.js:

  • Multiple p5 sketches on a same screen;
  • Multiple instances of one sketch mounted in a same component;
  • Mount sketches in different points of the DOM tree;
  • Dynamically switch on/off sketches;
  • p5.js libraries support (p5.sound example)
  • Bidirectional communication between the main React app and sketches;
  • Using the latest React features:
  • memo()
  • useContext()
  • useEffect()
  • useReducer()
  • Hot Module Replacement (HMR): exchanges, adds, or removes modules while an application is running, without a full reload. This can significantly speed up development in a few ways:
  • Retain application state which is lost during a full reload;
  • Save valuable development time by only updating what's changed.

Check the online version here.

The basic idea is that the p5.js sketch is wrapped in a React component. The data that comes into the sketch is passed on to this component as props. Callbacks are used to return information back from the sketch to the application.


Another examples, build on the same concept but using class-based components, can be found here and here.


Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode. Open http://localhost:8080 to view it in the browser. The page will reload if you make edits. You will also see any lint errors in the console.

npm run build

Builds the app for production to the build folder. It correctly bundles React in production mode and optimizes the build for the best performance. The build is minified and the filenames include the hashes. Your app is ready to be deployed.

Supported Language Features and Polyfills

This project supports a superset of the latest JavaScript standard.

Syntax Highlighting and Displaying Lint Output in the Editor

Тhe most popular editors should be covered and your editor should report the linting warnings.

Adding a Router and Redux

React Router is the most popular option.

Redux is a predictable state container for JavaScript apps.

React Router and Redux can easily be added to the project.


React is one of the most popular JavaScript libraries for creating single page applications.

p5.js is a JavaScript library with a full set of drawing functionality.

Core symbols most depended-on inside this repo

App
called by 0
src/components/App/index.jsx
AppStateProvider
called by 0
src/components/App/AppStateProvider/index.jsx
P5Wrapper
called by 0
src/components/P5Wrapper/index.jsx
Section31
called by 0
src/components/Section31/index.jsx
AppContent
called by 0
src/components/AppContent/index.jsx
Section4
called by 0
src/components/Section4/index.jsx
Section2
called by 0
src/components/Section2/index.jsx
Section3
called by 0
src/components/Section3/index.jsx

Shape

Function 9

Languages

TypeScript100%

Modules by API surface

src/components/Section4/index.jsx1 symbols
src/components/Section31/index.jsx1 symbols
src/components/Section3/index.jsx1 symbols
src/components/Section2/index.jsx1 symbols
src/components/Section1/index.jsx1 symbols
src/components/P5Wrapper/index.jsx1 symbols
src/components/AppContent/index.jsx1 symbols
src/components/App/index.jsx1 symbols
src/components/App/AppStateProvider/index.jsx1 symbols

For agents

$ claude mcp add react-hooks-p5js \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact