Skip to content

Instantly share code, notes, and snippets.

@pranitkhadilkar7
pranitkhadilkar7 / service.ts
Last active March 27, 2024 13:58
Code snippets for RTK Query api service
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
export const applicationApi = createApi({
reducerPath: 'applicationApi',
baseQuery: fetchBaseQuery({ baseUrl: 'http://localhost:3004/' }),
endpoints: () => ({}),
})
@pranitkhadilkar7
pranitkhadilkar7 / store.ts
Created March 27, 2024 13:41
src/store/store.ts file for RTK Query Setup
import { configureStore } from '@reduxjs/toolkit'
import { applicationApi } from './service'
import { setupListeners } from '@reduxjs/toolkit/query'
export const store = configureStore({
reducer: {
[applicationApi.reducerPath]: applicationApi.reducer,
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat(applicationApi.middleware),
@pranitkhadilkar7
pranitkhadilkar7 / index.tsx
Created March 27, 2024 13:43
src/index.tsx file for providing store object inside react application
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'
import reportWebVitals from './reportWebVitals'
import './styles/index.css'
import { Provider } from 'react-redux'
import { store } from './store/store'
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
root.render(
@pranitkhadilkar7
pranitkhadilkar7 / home-service.ts
Created March 27, 2024 13:48
src/pages/home/home-service.ts file for RTK Query endpoints specific to home page
import { applicationApi } from '../../store/service'
import { LatestRelease } from './home-type'
const homeService = applicationApi.injectEndpoints({
endpoints: (build) => ({
getLatestRelease: build.query<LatestRelease, void>({
query: () => ({
url: '/release/latest',
method: 'GET',
}),
@pranitkhadilkar7
pranitkhadilkar7 / Home.tsx
Created March 27, 2024 13:53
src/pages/home/Home.tsx component file to use functional hook exported from RTK Query endpoint
import { useGetLatestReleaseQuery } from './home-service'
export function Home() {
const { data, isLoading, isFetching } = useGetLatestReleaseQuery()
if (isLoading) return <div>Loading...</div>
if (isFetching) return <div>Fetching...</div>
if (data)
@pranitkhadilkar7
pranitkhadilkar7 / installation.sh
Last active April 6, 2025 08:48
Highcharts Installation in React Project
# Highcharts dependencies
# npm command
npm install highcharts highcharts-react-official
# yarn command
yarn add highcharts highcharts-react-official
@pranitkhadilkar7
pranitkhadilkar7 / LineChart.tsx
Last active April 6, 2025 09:02
Line Chart Example
import React from 'react';
import Highcharts from 'highcharts';
import HighchartsReact from 'highcharts-react-official';
const LineChart = () => {
const options = {
chart: {
type: 'line'
},
title: {
@pranitkhadilkar7
pranitkhadilkar7 / usage1.ts
Last active April 6, 2025 09:46
Usage of Highcharts Global Options
// Basic Usage
import Highcharts from 'highcharts';
Highcharts.setOptions({
// Global options that apply to all charts
chart: {
style: {
fontFamily: '"Arial", sans-serif'
}
},
@pranitkhadilkar7
pranitkhadilkar7 / GaugeChart.tsx
Created April 6, 2025 13:05
Chart Types Example
import Highcharts from 'highcharts';
import HighchartsReact from 'highcharts-react-official';
export const GaugeChart = () => {
const options = {
chart: {
type: 'gauge',
plotBorderWidth: 0,
plotShadow: false
},
@pranitkhadilkar7
pranitkhadilkar7 / event-handling.ts
Last active April 6, 2025 13:34
Event Handling
const options = {
chart: {
events: {
load: function() {
// Chart loaded callback
console.log('Chart loaded');
},
redraw: function() {
// Chart redrawn callback
console.log('Chart redrawn');