Skip to content

Commit

Permalink
fix: "nivo of undefined" error with Bar component on SSR (#42)
Browse files Browse the repository at this point in the history
* fix: "nivo of undefined" error with Bar component on SSR
* apply the same fix to the line & pie components

closes #41
  • Loading branch information
awareness481 authored Dec 23, 2021
1 parent a412c66 commit b7ff896
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matte-ui",
"version": "0.10.3",
"version": "0.10.4",
"description": "Matte is a UI component library on top of MUI and other react libraries.",
"author": "Squaredev",
"license": "Apache-2.0",
Expand Down
8 changes: 5 additions & 3 deletions src/components/dataviz/bar/bar.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ import { MatteTheme } from '../../utilities/createMatteTheme.component';
*/
// @ts-ignore
export const Bar: FC<BarSvgProps> = (props) => {
const { nivo }: MatteTheme = useTheme();
const theme: MatteTheme | null = useTheme();
const nivo = theme?.nivo;

return (
<ResponsiveBar
colors={nivo?.colorShemes?.mono}
colors={typeof nivo !== 'undefined' ? nivo?.colorShemes?.mono : null}
borderRadius={2}
innerPadding={3}
padding={0.5}
theme={nivo}
theme={typeof nivo !== 'undefined' ? nivo : null}
margin={{ top: 30, right: 20, bottom: 75, left: 50 }}
enableLabel={false}
legends={[
Expand Down
8 changes: 5 additions & 3 deletions src/components/dataviz/line/line.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import { MatteTheme } from '../../utilities/createMatteTheme.component';
* - Vary a line’s texture to represent different data types
*/
export const Line: FC<LineSvgProps> = (props) => {
const { nivo }: MatteTheme = useTheme();
const theme: MatteTheme | null = useTheme();
const nivo = theme?.nivo;

return (
<ResponsiveLine
colors={nivo?.colorShemes?.mono}
theme={nivo}
colors={typeof nivo !== 'undefined' ? nivo?.colorShemes?.mono : undefined}
theme={typeof nivo !== 'undefined' ? nivo : undefined}
margin={{ top: 30, right: 20, bottom: 50, left: 50 }}
axisLeft={{
tickValues: 5,
Expand Down
8 changes: 5 additions & 3 deletions src/components/dataviz/pie/pie.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import { MatteTheme } from '../../utilities/createMatteTheme.component';
*/
// @ts-ignore
export const Pie: FC<PieSvgProps> = (props) => {
const { nivo }: MatteTheme = useTheme();
const theme: MatteTheme | null = useTheme();
const nivo = theme?.nivo;

return (
<ResponsivePie
colors={nivo?.colorShemes?.mono}
theme={nivo}
colors={typeof nivo !== 'undefined' ? nivo?.colorShemes?.mono : null}
theme={typeof nivo !== 'undefined' ? nivo : null}
padAngle={1}
innerRadius={0.5}
cornerRadius={2}
Expand Down

0 comments on commit b7ff896

Please sign in to comment.