Back to blogs
Blog
Writing in public
Longer posts — published here first, then cross-posted to Dev.to with a canonical URL back to this site.
Blog
Longer posts — published here first, then cross-posted to Dev.to with a canonical URL back to this site.
Back to blogs
Back to blogs
Postreactic, react, context, tailwindcss
React icons are cool and all but tey do have that pesky issue of hvving to wrap them in an in order...
Date published

Why You Might Still Pick Next.js Over TanStack Start From a TanStack Start...

A complete theme management system for React applications with SSR support! ✨ 🌟...

slides used in the presentation building the generic component In this example we'll use...
React icons are cool and all but tey do have that pesky issue of hvving to wrap them in an <IconContext.provider> in order to be able to resize them or change their colors so i made this wrapper
1import React from 'react'2import { IconContext, IconType } from "react-icons";34type MyProps = {5 // using `interface` is also ok6 Icon: IconType;7 size: string;8 color: string;9 iconstyle?:string;10 iconAction?: () => any;11};12type MyState = {13 iconstyle: string;14};15export class TheIcon extends React.Component<MyProps, MyState> {16 constructor(props:MyProps) {17 super(props)18 this.state = { iconstyle:this.props?.iconstyle?this.props?.iconstyle:"" };19 this.clickAction = this.clickAction.bind(this);20 }21 clickAction(){22 if(this.props.iconAction){23 console.log("click action")24 return this.props.iconAction()25 }26 return console.log("")27 }28 render() {29 return (3031 <div>32 <IconContext.Provider value={{ size:this.props.size,color:this.props.color,33 className:this.state.iconstyle}}>34 <this.props.Icon onClick={()=>this.clickAction()}/>35 </IconContext.Provider>3637 </div>38 );39 }40}4142
example usage
1import { FaTimes} from "react-icons/fa";2import { TheIcon } from './../Shared/TheIcon';34<TheIcon Icon={ FaTimes } size={"34"} color={"green"} />5