Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 2 years ago

NextJS, Tailwind, React-Beautiful-DND, Next-themes

next, react
P
Thomas TS•1,690
@ttsoares
A solution to the Todo app challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


  • Next13 has some issues about themes. I was not able to fix the initial load error message about "Hydration". I know that there are workarounds by it is needed knowledge beyond be...
Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Alex Holguin•410
    @JAleXDesigN
    Posted about 2 years ago

    Hi, you can use npm install @wits/next-themes, I have used this a few times for themes in Next js with appDir and it works fine.

    You wrap the layout with the ServerThemeProvider

    import "./globals.css";
    import { Inter } from "next/font/google";
    import { ServerThemeProvider } from "@wits/next-themes";
    import Providers from "./Providers";
    
    const inter = Inter({ subsets: ["latin"] });
    
    export default function RootLayout({
    children,
    }: {
    children: React.ReactNode;
    }) {
    return (
    <ServerThemeProvider>
    <html lang="en">
    <body className={inter.className}>
    <Providers>{children}</Providers>
    </body>
    </html>
    </ServerThemeProvider>
    );
    }
    

    and for the client side provider you can do it in a separate component and use it in layout

    "use client";
    
    import type { FC, PropsWithChildren } from "react";
    
    import { ThemeProvider } from "@wits/next-themes";
    
    const Providers: FC<PropsWithChildren> = ({ children }) => {
    return <ThemeProvider>{children}</ThemeProvider>;
    };
    
    export default Providers;
    
    Marked as helpful
  • Yup•730
    @Yup03
    Posted almost 2 years ago

    Hi @ttsoares nice challenge

    First impression i wanted to put emphasis on is the structure of the todos array

    • I think you should whether have the completed property like so :
    {
        id: "item-1",
        content: "Complete entire javaScript course ",
        completed: false,   /*If the checkbox is "checked", the "completed" property will have "true" as value/ And your checkbox  "unchecked" will result this property becoming "false" */
      },
    
    • Or the active property :
    {
        id: "item-1",
        content: "Complete entire javaScript course ",
        active: true,  /*If the checkbox is "checked", the "active" property will have "false" as value/ And your checkbox  "unchecked" will result as "true" for this property  */
      },
    

    And your toggleCompleted function should take the id as argument due its uniqueness

    • Otherwise if you use the content, you can encounter many tasks that have the same content
    • And it's valable for the remove and toggleActive functions
    function toggleCompleted(id ) {/*instead of "todo"*/
        const result = todos.map((elm) => {
          if (elm.id === id) {
            return { ...elm, completed: !elm.completed };
          } else return elm;
        });
        setTodos(result);
        setBackTodos(result);
      }
    

    And as a result you'll also call toggleCompleted or remove or toggleActive functions with the id of your task like so :

    <div onClick={() => toggleCompleted(todo.id)}></div>
    

    At first sight, these are some point that i can highlight on your code; And i hope this will help you improve your solution

  • P
    Thomas TS•1,690
    @ttsoares
    Posted about 2 years ago
    • I did fix two accessibility problems and the screenshot. After update the repository, those changes will automatically reflect here ?

    • Most of the HTML Validation errors are code generated by the NextJS environment (Babel, etc...) and are not in my code.

    • Will that way to fix the Hydration problem... Thanks.

    EDITED: Just did the test and worked like a charm... :-)

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub