<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Everen-John</title>
    <description>The latest articles on Forem by Everen-John (@everenjohn).</description>
    <link>https://forem.com/everenjohn</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F571264%2Fc1543f73-6ac6-4ca2-a664-0eaeb4aee1b0.png</url>
      <title>Forem: Everen-John</title>
      <link>https://forem.com/everenjohn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/everenjohn"/>
    <language>en</language>
    <item>
      <title>How to center a single item (Tailwind CSS)</title>
      <dc:creator>Everen-John</dc:creator>
      <pubDate>Sun, 21 Nov 2021 10:53:31 +0000</pubDate>
      <link>https://forem.com/everenjohn/how-to-center-a-single-item-tailwind-css-2p3p</link>
      <guid>https://forem.com/everenjohn/how-to-center-a-single-item-tailwind-css-2p3p</guid>
      <description>&lt;p&gt;Need to center an item? Maybe a spinner in the middle of a screen?&lt;br&gt;
Cheat code to Center an item:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="flex justify-center"&amp;gt;
&amp;lt;div&amp;gt; whatever you wanna center here.&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>tailwindcss</category>
    </item>
    <item>
      <title>UseEffect Chaining?</title>
      <dc:creator>Everen-John</dc:creator>
      <pubDate>Thu, 11 Nov 2021 05:49:50 +0000</pubDate>
      <link>https://forem.com/everenjohn/useeffect-chaining-359i</link>
      <guid>https://forem.com/everenjohn/useeffect-chaining-359i</guid>
      <description>&lt;p&gt;Just a reminder that if you have many steps to render a page (e.g. multiple useEffects to render data), you can factorize all the steps in a promise.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    const loadPage = async () =&amp;gt; {
        return new Promise(async (resolve, reject) =&amp;gt; {
            let quizData = await getQuiz()
            let quill = await loadQuill()
            resolve({ quizData, quill })
        })
            .then(async ({ quizData }) =&amp;gt; {
                let answerSheet = generateAnswerSheet(quizData)
                return { answerSheet, quizData }
            })
            .then(async ({ answerSheet, quizData }) =&amp;gt; {
                setAnswerSheet(answerSheet)
                setQuizData(quizData)
            })
            .then(() =&amp;gt; {
                setQuizEnabled(true)
            })
            .catch((e) =&amp;gt; {
                window.alert("failed to load:", e)
            })
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Adding Quill Modules into ReactQuill in NextJS</title>
      <dc:creator>Everen-John</dc:creator>
      <pubDate>Thu, 21 Oct 2021 20:56:44 +0000</pubDate>
      <link>https://forem.com/everenjohn/adding-quill-modules-into-reactquill-in-nextjs-4pkj</link>
      <guid>https://forem.com/everenjohn/adding-quill-modules-into-reactquill-in-nextjs-4pkj</guid>
      <description>&lt;p&gt;I notice that there isn't a clear solution to adding Quill Modules into ReactQuill on NextJS yet. In this example, I am importing blotFormatter into Quill.&lt;/p&gt;

&lt;p&gt;The concept here is that since Quill needs document to be defined, we only tell Next to load in Quill and blotFormatter the moment the page is rendered. Since UseEffect only runs the moment the page renders, so we will start our call for these clientside imports there.&lt;/p&gt;

&lt;p&gt;We use &lt;code&gt;promise&lt;/code&gt; to ensure that Quill is loaded, and blot formatter is loaded, to be resolved so that the Quill.register function will be available to us.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let quillModules = {
    blotFormatter: {
        // see config options below
    },
    toolbar: [
        [{ header: [1, 2, 3, 4, 5, 6, false] }],
        ["bold", "italic", "underline", "strike", "blockquote"],
        [
            { list: "ordered" },
            { list: "bullet" },
            { indent: "-1" },
            { indent: "+1" },
        ],
        ["link", "image"],
        ["clean"],
    ],
}

let quillFormats = [
    "header",
    "bold",
    "italic",
    "underline",
    "strike",
    "blockquote",
    "list",
    "bullet",
    "indent",
    "link",
    "image",
]

export default function createDocument() {
    const [enableEditor, setEnableEditor] = useState(false)
    const [editorData, setEditorData] = useState("")

    const loadQuill = async () =&amp;gt; {
        return new Promise(async (resolve, reject) =&amp;gt; {
            const Quill = await require("react-quill").Quill
            const BlotFormatter = (await import("quill-blot-formatter")).default
            resolve({ Quill, BlotFormatter })
        })
            .then(({ Quill, BlotFormatter }) =&amp;gt; {
                Quill.register("modules/blotFormatter", BlotFormatter)
                return
            })
            .then((value) =&amp;gt; {
                setEnableEditor(true)
            })
    }

    useEffect(async () =&amp;gt; {
        await loadQuill()
    }, [])

    return (
            &amp;lt;div className='m-2 text-xs text-white'&amp;gt;
                    {enableEditor ? (
                        &amp;lt;div className='bg-white'&amp;gt;
                            &amp;lt;ReactQuill
                                value={editorData}
                                onChange={setEditorData}
                                modules={quillModules}
                                formats={quillFormats}
                            /&amp;gt;
                        &amp;lt;/div&amp;gt;
                    ) : null}
            &amp;lt;/div&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hopefully this hellps someone who struggles with this same problem as me!&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>reactquill</category>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
