'Cant use built in prop of Grommet Chart component with React/Typescript?
So, either I'm doing something wrong or something is broken. Am using Typescript React and I'm trying to render a Grommet component.
Documentation on Grommet Chart component: https://v2.grommet.io/chart
According to their docs, there is an 'id' Prop which I'm trying to use in order to map different visual types of graphs for each of my Cards. (there is line, bar, area, etc.) My code which I will show down below is also just a modification of their own code that they have in their Storybook.
import React from 'react';
import { Chart } from 'grommet';
import { Bitcoin, DocumentImage, Storage } from 'grommet-icons';
function TestPage() {
const gradient: {
value: number;
color: string;
}[] = [
{ value: 28, color: 'second' },
{ value: 50, color: 'main' },
{ value: 80, color: 'darkBlue' },
];
const dataArray: {
icon: JSX.Element;
title: string;
subTitle: string;
message: string;
style: any;
}[] = [
{
icon: <Bitcoin size='large' />,
title: 'title here',
subTitle: 'subtitle here',
message: 'blah blah',
style: 'line',
},
{
icon: <DocumentImage size='large' />,
title: 'title here',
subTitle: 'subtitle here',
message: 'blah blah',
style: 'bar',
},
{
icon: <Storage size='large' />,
title: 'title here',
subTitle: 'subtitle here',
message: 'blah blah',
style: 'area',
},
];
return (
<>
{dataArray.map((item: any) => {
return (
<Chart
id={item.title}
type={item.style}
dash={item.style === 'line'}
round
thickness='xsmall'
bounds={[
[0, 6],
[0, 100],
]}
values={[
{ value: [6, 100], label: 'one hundred' },
{ value: [5, 70], label: 'seventy' },
{ value: [4, 40], label: 'sixty' },
{ value: [3, 80], label: 'eighty' },
{ value: [2, 25], label: 'forty' },
{ value: [1, 50], label: 'thirty' },
{ value: [0, 25], label: 'sixty' },
]}
aria-label='chart card'
color={gradient}
size={{ height: 'xsmall' }}
/>
);
})}
</>
);
}
export default TestPage;
The id prop seems to be working in that when I do give it an id, it changes each Chart style accordingly (line, bar, and area) ...so it seems to work? However I get an error and Typescript complains. When I comment out the id prop, all of my Charts only show up as one type, 'line' but I dont get the error.
The error I get when I have id prop added is as follows. Even though with this error, id seems to work and it iterates through each Chart style (line, bar, area) and they appear on screen:
ERROR in src/Pages/TestPage.tsx:53:13
TS2322: Type '{ id: any; type: any; dash: boolean; round: true; thickness: string; bounds: number[][]; values: { value: number[]; label: string; }[]; "aria-label": string; color: { value: number; color: string; }[]; size: { height: string; }; }' is not assignable to type 'IntrinsicAttributes & ChartProps'.
Property 'id' does not exist on type 'IntrinsicAttributes & ChartProps'.
51 | return (
52 | <Chart
> 53 | id={item.title}
| ^^
54 | type={item.style}
55 | dash={item.style === 'line'}
56 | round
I'm pretty new to this but idk seems like something is messed up. If I make up a fake ChartProp called saladDressing and pass it through, I get the same error. Ex:
<Chart saladDressing={item.title} />
gives me "Property 'saladDressing does not exist on type 'IntrinsicAttributes & ChartProps"
But what has me confused is that the id seems to work, as when I have it uncommented, it changes the styles of each chart even though I get the error. What should I do to fix this or is there a way around it? Thanks.
Solution 1:[1]
You have to use the service name for connecting with the MySQL from Go application.
So your traffic flow like
Go appliction POD running inside same K8s cluster as POD inside the container
send a request to MySQL service -> MySQL service forward traffic to MySQL stateful sets (PODs or in other merge replicas)
So if you have created the service in your case host name will be service name : mysql
For example you can refer this : https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/
If you notice how WordPress is connceting to mysql
containers:
- image: wordpress:4.8-apache
name: wordpress
env:
- name: WORDPRESS_DB_HOST
value: wordpress-mysql
it's using the MySQL service name wordpress-mysql as hostname to connect.
If you just want to connect with Read Replica you can use the service name mysql-read
OR
you can also use try connecting with
kubectl run mysql-client --image=mysql:5.7 -i --rm --restart=Never --\ mysql -h mysql-0.mysql
Option -2
if you just to connect with specific POD or write a replica you can use the
<pod-name>.mysql
The Headless Service provides a home for the DNS entries that the StatefulSet controller creates for each Pod that's part of the set. Because the Headless Service is named mysql, the Pods are accessible by resolving .mysql from within any other Pod in the same Kubernetes cluster and namespace.
Solution 2:[2]
Another appropriate approach could be your application code ignores master, replica instance, etc and operates like it's connected to a single master instance and read, write query splitting is abstracted in a capable proxy. And that proxy is responsible for routing the write queries to the master instance and read queries to the replica instances. Example proxy - https://proxysql.com/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | shahin mahmud |
