teleren/devto huggingface dataset:
Working with `next/navigation` in Storybook
Tags: react, storybook, nextjs, testing
Published: 2024-01-14 13:23:09

# Background

I was working on integrating Storybook process into legacy system using next. The thing is, some of the components are dependent on the `useRouter()` hook from `next/navigation`. I'm planning to document how to work with those and fix getting errors like:

```
Error: invariant expected app router to be mounted
```

# Approach

TL;DR Use context provider with mock value. Like:

```ts
<AppRouterContext.Provider value={mockRouter}>
  <Component {...args} />
</AppRouterContext.Provider>
```

# Setup

Import dependency like this on your Storybook. Example, I have this page component I want to render on storybook.

```ts
// src/app/login/page.tsx
import { useRouter } from 'next/navigation';

const REGISTER_ROUTE = '/register';

export default function LoginPage() {
  const router = useRouter(); // The offending line

  return (
    <div>
      <button onClick={() => router.push(REGISTER_ROUTE)}>
        Register
      </button>
    </div>
  )

}

```

With Storybook story like:

```ts
// src/stories/LoginPage.stories.tsx
import type { Meta, StoryObj } from 'storybook/react';

import Component from '@app/login';

const meta = {
  title: 'Login Page',
  component: Component,
  tags: ['autodocs'],
} satisfies Meta<typeof Component>;

export default meta;

type Story = StoryObj<typeof meta>;

export const DefaultView: Story = {};
```

This won't run and will fail.

# Solution

Update the storybook and wrap component in next `AppRouterContext`.

```diff
// src/stories/LoginPage.stories.tsx
import type { Meta, StoryObj } from 'storybook/react';
+ import {
+   AppRouterContext,
+   AppRouterInstance,
+ } from 'next/dist/shared/lib/app-router-context';

import Component from '@app/login';

const meta = {
  title: 'Login Page',
  component: Component,
  tags: ['autodocs'],
} satisfies Meta<typeof Component>;

+ // I tried empty functions, but I think mock function would
+ // be better? See: `vi.fn()`
+ const mockRouter: AppRouterInstance = {
+   back: () => {},
+   forward: () => {},
+   prefetch: () => {},
+   push: () => {},
+   refresh: () => {},
+   replace: () => {},
+ }

export default meta;

type Story = StoryObj<typeof meta>;

- export const DefaultView: Story = {};
+ export const DefaultView: Story = {
+   render: (args) => )
+     <AppRouterContext.Provider value={mockRouter}>
+       <Component {...args} />
+     </AppRouterContext.Provider>
+   ),
+ };

```
ركز معي: رحلتي في عالم البرمجة وخبرتي العملية بالبايثون
Tags: python, c, net, sql
Published: 2024-01-14 13:09:40

مقدمة:
تعد رحلة البرمجة رحلة مثيرة ومليئة بالتحديات والفرص. في هذه المقالة، سأشاركك تجربتي الشخصية في عالم البرمجة وخبرتي العملية بلغة البايثون على مدار أكثر من 8 أعوام. سنلقي نظرة على المشاريع الرئيسية التي عملت عليها والتحديات التي واجهتها، بالإضافة إلى اللغات البرمجية الأخرى التي أتقنها.
الجزء الأول: بداية الرحلة
في عام 2014، بدأت رحلتي في عالم البرمجة. كانت لدي شغف كبير لاستكشاف قوة البرمجة وتطبيقها في حل المشاكل وتحقيق الأفكار الإبداعية. اخترت لغة البايثون كنقطة انطلاق لمسيرتي، وهي اللغة التي أصبحت رفيقي المفضل في رحلتي.
الجزء الثاني: المشاريع الرئيسية
1. 
تطوير مشروع LIFI:
أحد أبرز المشاريع التي عملت عليها هو تطوير مشروع LIFI وجعله يشبه WIFI. قمت بتطوير نظام يستخدم تقنية الإضاءة المرئية لنقل البيانات بسرعة عالية وأمان متفوق. كان هذا المشروع تحدًا كبيرًا وفرصة لتطبيق مهاراتي في البرمجة والاتصالات.
2. 
بناء روبوت متكامل في التداول بالذكاء الاصطناعي لمنصات الميتاتريدر:
عملت أيضًا على مشروع بناء روبوت متكامل يستخدم التداول بالذكاء الاصطناعي على منصات الميتاتريدر. قمت بتطوير نظام يستند إلى خوارزميات التعلم الآلي لاتخاذ قرارات التداول بناءً على تحليلات السوق والبيانات المالية.
3. 
مودل متكامل في النطق والتفريغ الصوتي والتعرف على الصوت بالذكماعي, في هذا المشروع قمت بتطوير نظام متكامل يستخدم الذكاء الاصطناعي للتعرف على الصوت وتحويله إلى نص مكتوب. قمت بتدريب نماذج التعلم العميق على مجموعة واسعة من اللغات لتمكين التعرف على الصوت بدقة عالية وتحويله إلى نص قابل للقراءة والتحرير.
4. 
نظام متكامل لأتمتة المواقع الخاصة والعامة:
عملت أيضًا على تطوير نظام متكامل لأتمتة المواقع الخاصة والعامة. قمت بتصميم وتنفيذ نظام يستخدم تقنيات البرمجة وقواعد البيانات لتحسين كفاءة وأمان المواقع وتحقيق التفاعلية والتجربة المستخدم الممتازة.
الجزء الثالث: التطور والتعمق
منذ بداية رحلتي في عالم البرمجة وحتى الآن، لم أتوقف عن التطور والتعمق في هذا المجال المثير. قمت بتعلم العديد من اللغات البرمجية الأخرى بالإضافة إلى البايثون، مثل C++ وجافا وجافا سكريبت وغيرها. أصبحت قادرًا على التعامل مع قواعد البيانات باستخدام SQL وتطوير تطبيقات الويب باستخدام إطارات عمل مثل Django.
الخاتمة:
تجربتي في عالم البرمجة كانت مليئة بالتحديات والفرص. من خلال المشاريع التي عملت عليها، استطعت تطوير مهاراتي في البرمجة وتوسيع معرفتي في مجالات متعددة. أنا متحمس للاستمرار في رحلتي ومواصلة التعلم والتطوير في عالم البرمجة. إذا كان لديك أي أسئلة أو تحديات برمجية، فأنا هنا للمساعدة والمشاركة في رحلتك أيضًا.

لا أنسى أن اخبركم بأكثر وسيلة اتواجد فيها هي التيليجرام... وعبر المعرف: @QaYeDev
Vashikaran Mantra for Parents Approval In Hyderabad
Published: 2024-01-14 12:58:19

**[Vashikaran Mantra for Parents Approval In Hyderabad](https://onlineloveproblemsolutionastrologer.com/blog/2024/01/14/vashikaran-mantra-for-parents-approval-in-hyderabad/)** is a practice that some individuals believe can help them gain the approval of their parents for various matters in the city of Hyderabad, India. It involves the recitation of specific mantras or chants with the intention of influencing the thoughts and decisions of parents regarding a particular issue, such as marriage, career, or personal choices.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ufbir57hvxtd6ih71nr.png)
It is important to note that the effectiveness and ethical implications of such practices are highly debated. While some people claim positive outcomes, others may view it as manipulative or unethical. It is always recommended to seek open and honest communication with parents and to respect their choices and opinions.

It is crucial to approach important life decisions with understanding, empathy, and mutual respect for all parties involved. Building trust and maintaining healthy relationships are essential in resolving conflicts and gaining parental approval.

It is important to exercise caution and critical thinking when engaging with any spiritual or supernatural practices. It is always advisable to consult with trusted professionals or seek guidance from reputable sources before making any decisions.

**If you have any query or want to know more about this you can consult with [Love Problem Solution Astrologer](https://onlineloveproblemsolutionastrologer.com/) Arjun Shastri Ji on Phone Call or through Whatsapp Call on [+91-9929942354](tel:+91-9929942354)**
React curly braces
Published: 2024-01-14 12:53:37

JSX curly braces can be used either between an opening HTML tag and closing HTML tag or after an HTML attribute. JSX curly can convert a JavaScript number, string into a string. It works both for HTML text and HTML attribute.

```JSX
const numberForHTMLText = 20;
const stringForHTMLText = "This is a string for HTML text.";

const numberForHTMLAttribute = 30;
const stringForHTMLAttribute = "This is a string for HTML attribute.";

export default function App() {
  return (
    <>
      <h1>JSX convert a JavaScript number and string into a string.</h1>

      <h2>For HTML Text</h2>
      <h3>A number for HTML text</h3>
      <p>This is a number: {numberForHTMLText}</p>
      <h3>A string for HTML text</h3>
      <p>This is a string: {stringForHTMLText}</p>

      <h2>For HTML attribute</h2>
      <h3>A number for HTML attribute</h3>
      <p number={numberForHTMLAttribute}>This is a number.</p>
      <h3>A string for HTML attribute</h3>
      <p string={stringForHTMLAttribute}>This is a string.</p>
    </>
  );
}

```
JSX curly braces can even convert a JavaScript object into a stirng, while it can only work for HTML style attribute with some certain properties. You can use either an object variable name or javaScript object literal.
```JSX
const objectForHTMLAttribute = {
  width: 90,
  height: 90,
};

export default function App() {
  return (
    <>
      <h1>JSX convert a JavaScript number and string into a string.</h1>

      <h2>For HTML attribute</h2>
      <h3>An object for HTML attribute</h3>
      <p style={objectForHTMLAttribute}>This is an object.</p>
      <p style={{ width: 90, height: 90 }}>This is an object.</p>
    </>
  );
}
```
Resolve “TailwindCSS Not Working in React-TypeScript Project with Vite” In Two Minutes!
Tags: react, typescript, vite, tailwindcss
Published: 2024-01-14 12:24:15

Developers may face issues configuring Tailwind CSS in React projects built with TypeScript and Vite. These challenges can result in styles not being applied as expected, very FRUSTRATING!

Well, I was stuck too. Let’s explore a quick and effective way to start a React project with TypeScript and Tailwind CSS.

I tried many solutions online yet I could not find a suitable solution for my existing project.

To overcome these hurdles, follow these straightforward steps provided in the official Tailwind CSS documentation ( except for the first command) tailored for Vite React projects.
##Step 1: Create a New File
Begin by creating a new file in your project. This file will serve as the entry point for Tailwind CSS configuration.
##Step 2: Add react-ts to the Command
Refer to the official [Tailwind CSS documentation](https://tailwindcss.com/docs/guides/vite) for Vite and React projects. Make sure to navigate to the section specific to Vite. For TypeScript support, use the following command instead of the given command.
```
npm create vite@latest my-project --template react-ts // add -ts
```
This command initializes a new Vite project with the React-TS template, laying the foundation for a smooth integration with Tailwind CSS.
##Step 3: Follow Remaining Documentation
Continue following the remaining steps outlined in the official Tailwind CSS documentation. These steps typically include installing dependencies, configuring your PostCSS and Tailwind CSS settings, and importing styles into your project.

Well, there you have it! Empower your React-TS development journey by implementing these solutions, and enjoy the seamless synergy between #React, #TypeScript, #Vite, and #TailwindCSS. Happy coding!

Share how you solved your problem in the comment below!!!
Luna: The AI Assistant That Elevates Your Desktop Experience!
Published: 2024-01-14 11:59:24

Are you an intermediate Python developer looking to streamline your workflow? Meet **Luna**, the versatile AI assistant that's here to revolutionize the way you interact with your digital environment. 🚀

**Why Luna?**
- **Voice-Activated Efficiency**: Say goodbye to manual task handling. With Luna, command your computer through voice and watch as she automates tasks, manages files, and even sends WhatsApp messages!
- **Developer-Friendly Design**: Luna is crafted with Python enthusiasts in mind. Her code is organized, documented, and perfect for those looking to delve deeper into AI-assisted programming.
- **Open-Source Collaboration**: Dive into Luna's code on GitHub, contribute to her growth, and join a community of developers enhancing her capabilities.

**Key Features:**
- **Desktop Automation**: Control your system effortlessly.
- **WhatsApp Integration**: Send messages without lifting a finger.
- **Task Scheduling**: Keep your projects on track with automated reminders.

**Get Started with Luna:**
- **Easy Setup**: Follow the README for a smooth installation.
- **Customizable**: Tailor Luna to your needs with API keys and personalized settings.

**Join the Luna Community:**
- **Contribute**: Enhance Luna's abilities by contributing to her repository.
- **Feedback**: please Share your experience in comments and help to shape Luna's future updates.

Ready to boost your productivity? Check out Luna on GitHub and let her transform your coding journey! 👩‍💻✨

🔗 [Explore Luna on GitHub]
https://github.com/GitCoder052023/Luna

*Note: Luna is in active development. Your contributions and feedback are invaluable in making her the best AI assistant for developers!*
Telegraf JS: Library for creating telegram bot using Javascript
Tags: javascript, node, telegram
Published: 2024-01-14 11:58:41

We can use any programming languages for develop a telegram bot like PHP, C#, Python...
in this article we used JavaScript for develop telegram bot.

1- In first we need to install Nodejs and NPM ([Link](https://nodejs.org/en)).
2- Next step, create an directory so open Terminal or CMD on your project directory, so run this command:

```
npm init --y
```
3- For develop, we need TelegrafJS library. So run this command:

```
npm i --save telegraf
```
4- create index.js file
5- open project on your code editor like VSCode, Notepad++, ...
6- open index.js and write the following code:

```JavaScript
const {Telegraf} = requrie("telegraf")

const bot = new Telegraf("YOUR_BOT_TOKEN")

// When user send /start command
bot.start((ctx) => ctx.reply('Welcome'))

bot.launch();
```
7- For run bot, write and run this command on terminal:

```
node .
```

Extra information about TelegrafJS and documentation: [TelegrafJS Doc](https://telegraf.js.org/classes/Telegraf-1.html)

**Example**
I create a simple bot for check user join to telegram channel or no

```JavaScript
const { Telegraf } = require('telegraf');

// Replace 'YOUR_BOT_TOKEN' with your Telegram Bot API token
const bot = new Telegraf('YOUR_BOT_TOKEN');

// Middleware function to check if a user has joined a channel
function checkChannelJoin(ctx, next) {
  const channelId = '@YourChannelUsername'; // Replace with your channel's username or ID
  const userId = ctx.from.id;

  // Check if the user is a member of the channel
  bot.telegram.getChatMember(channelId, userId)
    .then((chatMember) => {
      if (chatMember.status === 'member' || chatMember.status === 'creator' || chatMember.status === 'administrator') {
        // User is a member of the channel
        console.log(`User is a member of the channel.`);
        next();
      } else {
        // User is not a member of the channel
        console.log(`User ${userId} is not a member of the channel.`);
        ctx.reply(`
        Please join our channel to access the bot functionality.
        ${channelId}
        `);
      }
    })
    .catch((error) => {
      console.log('Error:', error);
      ctx.reply('Oops! Something went wrong. Please try again later.');
    });
}

// Command handler for '/start' command
bot.command('start', checkChannelJoin, (ctx) => {
  ctx.reply('Welcome to the bot!');
});

// Start the bot
bot.launch();

```
Note: This script, when the user send /start command in your bot, checks whether the user has subscribed to your Telegram channel (using the middleware), if yes, it executes the next step and Otherwise, it requires the user to join.
Trending APK Gaming Website (FindMobAPK)
Tags: gamedev, apk, website, mobile
Published: 2024-01-14 11:53:23

Welcome to FindMobAPK, your premier destination for a diverse and extensive collection of APK games and apps. At [FindMobAPK](https://findmobapk.com/), we are dedicated to providing users with a seamless and immersive experience, bringing you the latest and most sought-after mobile applications and games.

Our platform is designed to cater to the ever-evolving needs and preferences of our users, offering a curated selection of high-quality APKs that span various categories. Whether you're a gaming enthusiast, productivity seeker, or entertainment lover, FindMobAPK has something for everyone.

What sets FindMobAPK apart is our commitment to ensuring that every app and game featured on our platform undergoes thorough scrutiny for quality, security, and user satisfaction. We understand the importance of a safe and reliable source for your digital downloads, and our team works tirelessly to provide you with a trustworthy environment.

Navigating through FindMobAPK is a breeze, thanks to our user-friendly interface that allows you to discover, download, and enjoy your favorite apps with just a few clicks. Our search and categorization features make finding the perfect app a quick and efficient process.

Whether you're looking for the hottest trending games, productivity-boosting applications, or unique and niche apps, FindMobAPK is your go-to destination. Stay updated with the latest releases and discover hidden gems that might have slipped under your radar.

At FindMobAPK, we believe in fostering a community of mobile enthusiasts who share a passion for innovation and exploration. Join us on this exciting journey as we continue to expand our collection and provide you with the best APKs the digital world has to offer.

Explore the possibilities, discover new favorites, and elevate your mobile experience with FindMobAPK – your ultimate destination for APK games and apps.
Software Testing Tutorial For Beginners
Tags: webdev, java, html, beginners
Published: 2024-01-14 11:45:59

A **[software testing tutorial](https://www.javatpoint.com/software-testing-tutorial)** is a learning resource or guide that provides information and instructions on various aspects of software testing. Software testing is a crucial process in the software development lifecycle, aimed at identifying defects or errors in a software application to ensure its quality and reliability.

A software testing tutorial typically covers a wide range of topics related to testing methodologies, techniques, tools, and best practices. It may include both theoretical concepts and practical examples to help individuals understand how to effectively test software for different types of applications.

Key components of a software testing tutorial may include:

Introduction to Software Testing: An overview of the importance of software testing, its objectives, and its role in the development process.

Testing Life Cycle: Explanation of the different phases of the testing process, such as requirement analysis, test planning, test design, test execution, and defect tracking.

Types of Testing: Information about various types of testing, including functional testing, non-functional testing, manual testing, automated testing, and performance testing.

Testing Techniques: Discussion on different testing techniques like black-box testing, white-box testing, gray-box testing, and regression testing.

Testing Tools: Introduction to popular testing tools that aid in the automation and management of testing processes.

Test Cases and Scenarios: Guidance on creating effective test cases and scenarios to ensure comprehensive test coverage.

Bug Tracking: Information on how to identify, report, and manage software defects or bugs.

Best Practices: Recommendations for following industry best practices in software testing to achieve optimal results.

Challenges in Testing: Discussion on common challenges faced during the testing process and strategies to overcome them.

Real-world Examples: Practical examples and case studies to illustrate how testing concepts are applied in real software projects.
Problem solving for developers (4 steps)
Tags: programming, webdev, javascript, beginners
Published: 2024-01-14 11:31:12

## 🍃Introduction:

For many new coders, problem-solving can feel like trying to solve a [puzzle blindfolded](https://en.wikipedia.org/wiki/Blind_man%27s_buff#:~:text=Blind%20man's%20buff%20is%20played,%22it%22%2C%20hiding%20in%20plain). 

![Image of puzzle solving](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ryrpd7i5ldv9x9kl0v2c.gif)

You may know the rules and tools, but how to put them together is the REAL CHALLENGE.

Let's start with the <u>THREE MAJOR STEPS</u> in problem-solving:

## 🔍1. Know your problem:

Imagine trying to solve a puzzle without knowing what the picture looks like. 

Not EASY, right? 

Let me make it EASY for you. Your first step in solving a problem is to UNDERSTAND the problem. 

Write it down, reword it in SIMPLE English, and draw pictures if needed. 

If you can explain it to a friend, you're on the right track. 

## 📝2. Plan:

Don't rush into coding just yet! Plan out HOW you'll solve the problem. 

What will your program look like? 

What inputs will it take? 

What's the EXPECTED output? 

Create a recipe (algorithm) in pseudocode, a friendly language that helps you <u>think through the steps</u>.

### 📔Pseudocode:

Pseudocode is like talking to your computer in PLAIN English. It's a roadmap for your program without the complex code. 


For example, instead of saying "if x is greater than y," you'd say, "when the user gives a number, start counting from zero and print each number until you reach their number."

## 🗡️3. Divide and Conquer:

![Image of programmer solving problems like a warrior](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iy7w9h1zphon84lg7xv2.gif)

Big problems are like GIANT puzzles. 

Break them into smaller, solvable pieces. 

Focus on the TINY steps first. 

Solve one, and it might show you the way to the NEXT. 


DO NOT TRY to tackle the whole thing at once – it's like eating a pizza in one bite. Not fun and effective!

---

_You can watch my short animated video regarding this article:_

{% youtube https://youtu.be/1Kig9--UbJ8 %}


## 😎 Conclusion:

So, in summary, take it <u>step by step</u>, <u>understand</u> the problem, plan your attack in <u>pseudocode</u>, and conquer the challenges one <u>mini-problem at a time</u>. 

Soon, you'll be start solving problems like a PRO! 

Thanks for reading this article. Don’t forget to subscribe to my [YouTube channel](https://www.youtube.com/channel/UCyQg06zsc9tBtjgpQ_k8wUg) to learn programming effectively. 

Comment below with your thoughts. It might help someone.