mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-12-12 12:22:32 -05:00
Revert "Merge pull request #15 from neynarxyz/shreyas-formatting"
This reverts commitb1fdfc19a9, reversing changes made tob9e2087bd8.
This commit is contained in:
@@ -1,24 +1,19 @@
|
||||
'use client';
|
||||
"use client";
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { useMiniApp } from '@neynar/react';
|
||||
import { Footer } from '~/components/ui/Footer';
|
||||
import { Header } from '~/components/ui/Header';
|
||||
import {
|
||||
HomeTab,
|
||||
ActionsTab,
|
||||
ContextTab,
|
||||
WalletTab,
|
||||
} from '~/components/ui/tabs';
|
||||
import { USE_WALLET } from '~/lib/constants';
|
||||
import { useNeynarUser } from '../hooks/useNeynarUser';
|
||||
import { useEffect } from "react";
|
||||
import { useMiniApp } from "@neynar/react";
|
||||
import { Header } from "~/components/ui/Header";
|
||||
import { Footer } from "~/components/ui/Footer";
|
||||
import { HomeTab, ActionsTab, ContextTab, WalletTab } from "~/components/ui/tabs";
|
||||
import { USE_WALLET } from "~/lib/constants";
|
||||
import { useNeynarUser } from "../hooks/useNeynarUser";
|
||||
|
||||
// --- Types ---
|
||||
export enum Tab {
|
||||
Home = 'home',
|
||||
Actions = 'actions',
|
||||
Context = 'context',
|
||||
Wallet = 'wallet',
|
||||
Home = "home",
|
||||
Actions = "actions",
|
||||
Context = "context",
|
||||
Wallet = "wallet",
|
||||
}
|
||||
|
||||
export interface AppProps {
|
||||
@@ -27,39 +22,44 @@ export interface AppProps {
|
||||
|
||||
/**
|
||||
* App component serves as the main container for the mini app interface.
|
||||
*
|
||||
*
|
||||
* This component orchestrates the overall mini app experience by:
|
||||
* - Managing tab navigation and state
|
||||
* - Handling Farcaster mini app initialization
|
||||
* - Coordinating wallet and context state
|
||||
* - Providing error handling and loading states
|
||||
* - Rendering the appropriate tab content based on user selection
|
||||
*
|
||||
*
|
||||
* The component integrates with the Neynar SDK for Farcaster functionality
|
||||
* and Wagmi for wallet management. It provides a complete mini app
|
||||
* experience with multiple tabs for different functionality areas.
|
||||
*
|
||||
*
|
||||
* Features:
|
||||
* - Tab-based navigation (Home, Actions, Context, Wallet)
|
||||
* - Farcaster mini app integration
|
||||
* - Wallet connection management
|
||||
* - Error handling and display
|
||||
* - Loading states for async operations
|
||||
*
|
||||
*
|
||||
* @param props - Component props
|
||||
* @param props.title - Optional title for the mini app (defaults to "Neynar Starter Kit")
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* <App title="My Mini App" />
|
||||
* ```
|
||||
*/
|
||||
export default function App(
|
||||
{ title }: AppProps = { title: 'Neynar Starter Kit' },
|
||||
{ title }: AppProps = { title: "Neynar Starter Kit" }
|
||||
) {
|
||||
// --- Hooks ---
|
||||
const { isSDKLoaded, context, setInitialTab, setActiveTab, currentTab } =
|
||||
useMiniApp();
|
||||
const {
|
||||
isSDKLoaded,
|
||||
context,
|
||||
setInitialTab,
|
||||
setActiveTab,
|
||||
currentTab,
|
||||
} = useMiniApp();
|
||||
|
||||
// --- Neynar user hook ---
|
||||
const { user: neynarUser } = useNeynarUser(context || undefined);
|
||||
@@ -67,7 +67,7 @@ export default function App(
|
||||
// --- Effects ---
|
||||
/**
|
||||
* Sets the initial tab to "home" when the SDK is loaded.
|
||||
*
|
||||
*
|
||||
* This effect ensures that users start on the home tab when they first
|
||||
* load the mini app. It only runs when the SDK is fully loaded to
|
||||
* prevent errors during initialization.
|
||||
@@ -115,12 +115,9 @@ export default function App(
|
||||
{currentTab === Tab.Wallet && <WalletTab />}
|
||||
|
||||
{/* Footer with navigation */}
|
||||
<Footer
|
||||
activeTab={currentTab as Tab}
|
||||
setActiveTab={setActiveTab}
|
||||
showWallet={USE_WALLET}
|
||||
/>
|
||||
<Footer activeTab={currentTab as Tab} setActiveTab={setActiveTab} showWallet={USE_WALLET} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user