Posts

Showing posts with the label React

Create a lean React Solution using Typescript

 Make sure you have node and npm installed Directory Setup 1. npm run init 2. create public and src folder 3. Add index.html in public folder 4. Add index.tsx in src folder Add Dependencies npm install react react-dom Add Dev Dependencies npm install typescript webpack webpack-cli webpack-dev-server ts-loader html-webpack-plugin  --save-dev  npm i --save-dev @types/react-dom typed-scss-modules  Add Configuration and Code Add code to src\index.tsx https://github.com/sagarpandey88/templates/blob/main/typescript-react/src/index.tsx Add webpack.config.js https://github.com/sagarpandey88/templates/blob/main/typescript-react/webpack.config.js Add tsconfig.json https://github.com/sagarpandey88/templates/blob/main/typescript-react/tsconfig.json Run the code npm run build npm run start

Usecontext React Simple Example

Have recently bumped upon a very nice and simple example to use UseContext in React to share variable and methods across all the components. Reference Link