Skip to content

Commit

Permalink
Fix. Setting. React components i18n fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glomberg committed Oct 14, 2024
1 parent 4c8aba9 commit 358c59b
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 320 deletions.
295 changes: 5 additions & 290 deletions js/spbc-react-bundle.js

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions js/src/react/components/SpbctAboutCT.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from 'react';
import {useI18n} from '@wordpress/react-i18n';
const { __, _x, _n, _nx } = wp.i18n;

export function SpbctAboutCT(props) {

const {__} = useI18n();

// @ToDO Need to set state 'data'?
//this.state = {date: new Date()};
const data = props.data;
Expand Down
4 changes: 1 addition & 3 deletions js/src/react/components/SpbctPage.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, {useEffect} from 'react';
import {useI18n} from '@wordpress/react-i18n';
import {SpbctAboutCT} from './SpbctAboutCT';
const { __, _x, _n, _nx } = wp.i18n;

export function SpbctPage(props) {

const {__} = useI18n();

// @ToDO Need to set state 'data'?
//this.state = {date: new Date()};

Expand Down
4 changes: 1 addition & 3 deletions js/src/react/components/SpbctPageTabs.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React, {useEffect} from 'react';
import {useI18n} from '@wordpress/react-i18n';
const { __, _x, _n, _nx } = wp.i18n;

export function SpbctPageTabs(props) {

const {__} = useI18n();

// @ToDO Need to set state 'data'?
//this.state = {date: new Date()};

Expand Down
21 changes: 3 additions & 18 deletions js/src/react/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import {createI18n} from '@wordpress/i18n';
import {I18nProvider} from '@wordpress/react-i18n';
const i18n = createI18n();
import {SpbctPage} from './components/SpbctPage';
import {SpbctPageTabs} from './components/SpbctPageTabs';
import {SpbctAboutCT} from './components/SpbctAboutCT';
Expand All @@ -22,11 +19,7 @@ addEventListener('spbctPage', (event) => {
return;
}

root.render(
<I18nProvider i18n={i18n}>
<SpbctPage data={data} />
</I18nProvider>
);
root.render(<SpbctPage data={data} />);
}
if (aboutCTElement !== null) {

Expand All @@ -39,11 +32,7 @@ addEventListener('spbctPageTabs', (event) => {

if (targetElement !== null) {
const root = ReactDOM.createRoot(targetElement);
root.render(
<I18nProvider i18n={i18n}>
<SpbctPageTabs data={data} />
</I18nProvider>
);
root.render(<SpbctPageTabs data={data} />);
}
});

Expand All @@ -53,10 +42,6 @@ addEventListener('spbctMobAboutCT', (event) => {

if (targetElement !== null) {
const root = ReactDOM.createRoot(targetElement);
root.render(
<I18nProvider i18n={i18n}>
<SpbctAboutCT data={data} />
</I18nProvider>
);
root.render(<SpbctAboutCT data={data} />);
}
});
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"@wordpress/i18n": "^5.9.0",
"@wordpress/react-i18n": "^4.9.0"
"webpack-cli": "^4.10.0"
}
}

0 comments on commit 358c59b

Please sign in to comment.