Skip to content

Commit 2c0f028

Browse files
committed
updated p5version approach
1 parent 3026318 commit 2c0f028

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

client/modules/IDE/components/About.jsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React from 'react';
2+
import { useSelector } from 'react-redux';
23
import { Helmet } from 'react-helmet';
3-
import axios from 'axios';
44
import { useTranslation } from 'react-i18next';
55
import { Link } from 'react-router';
66
import SquareLogoIcon from '../../../images/p5js-square-logo.svg';
@@ -10,12 +10,10 @@ import packageData from '../../../../package.json';
1010

1111
function About(props) {
1212
const { t } = useTranslation();
13-
const [p5version, setP5version] = useState(0);
14-
useEffect(() => {
15-
axios
16-
.get('https://cdn.jsdelivr.net/npm/p5/package.json')
17-
.then((data) => setP5version(data?.data?.version));
18-
}, []);
13+
const p5version = useSelector((state) => {
14+
const index = state.files.find((file) => file.name === 'index.html');
15+
return index?.content.match(/\/p5\.js\/([\d.]+)\//)?.[1];
16+
});
1917
return (
2018
<div className="about__content">
2119
<Helmet>

0 commit comments

Comments
 (0)