<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jake Borromeo on Medium]]></title>
        <description><![CDATA[Stories by Jake Borromeo on Medium]]></description>
        <link>https://medium.com/@jake-borromeo?source=rss-446fbab18de1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wJz9tk0mW6aHI3EQel4XYg.jpeg</url>
            <title>Stories by Jake Borromeo on Medium</title>
            <link>https://medium.com/@jake-borromeo?source=rss-446fbab18de1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 17:51:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jake-borromeo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[sfmc Engagement queries]]></title>
            <link>https://jake-borromeo.medium.com/sfmc-engagement-queries-72c9012cc8fd?source=rss-446fbab18de1------2</link>
            <guid isPermaLink="false">https://medium.com/p/72c9012cc8fd</guid>
            <dc:creator><![CDATA[Jake Borromeo]]></dc:creator>
            <pubDate>Mon, 22 Jan 2024 21:01:41 GMT</pubDate>
            <atom:updated>2024-01-23T18:58:13.675Z</atom:updated>
            <content:encoded><![CDATA[<pre>SELECT<br>    j.ContactKey,<br>    j.JourneyName,<br>    j.JourneyID,<br>    COUNT(DISTINCT s.EventDate) AS NumSends,<br>    COUNT(DISTINCT o.EventDate) AS NumOpens,<br>    COUNT(DISTINCT c.EventDate) AS NumClicks,<br>    sl.CardMemberField1,<br>    sl.CardMemberField2<br>    -- Add more fields from SendLog as needed<br>FROM<br>    _JourneyActivity j<br>LEFT JOIN<br>    _Sent s ON j.TriggererSendDefinitionObjectID = s.SendDefinitionObjectID<br>          AND j.ContactKey = s.SubscriberKey<br>LEFT JOIN<br>    _Click c ON j.TriggererSendDefinitionObjectID = c.SendDefinitionObjectID<br>           AND j.ContactKey = c.SubscriberKey<br>LEFT JOIN<br>    _Open o ON j.TriggererSendDefinitionObjectID = o.SendDefinitionObjectID<br>          AND j.ContactKey = o.SubscriberKey<br>LEFT JOIN<br>    SendLog sl ON s.JobID = sl.JobID<br>           AND s.ListID = sl.ListID<br>           AND s.BatchID = sl.BatchID<br>           AND s.SubscriberID = sl.SubscriberID<br>WHERE<br>    j.JourneyID = 8282<br>    AND j.JourneyName = &#39;HelloWorld&#39;<br>GROUP BY<br>    j.ContactKey, j.JourneyName, j.JourneyID, sl.CardMemberField1, sl.CardMemberField2</pre><p>get all users: <a href="https://gist.github.com/camrobert/bef7ab83a6245c7db40dd30c3f25f755">https://gist.github.com/camrobert/bef7ab83a6245c7db40dd30c3f25f755</a> <a href="https://gist.github.com/camrobert"><br>camrobert</a>/<a href="https://gist.github.com/camrobert/bef7ab83a6245c7db40dd30c3f25f755">SSJS Get all Users</a></p><pre><br>&lt;script runat=&quot;server&quot;&gt;<br>/*Code provided as is without warranty - make sure you understand what this code does before using it - use at your own risk*/<br>Platform.Load(&quot;Core&quot;,&quot;1&quot;);<br>try {<br>  var prox = new Script.Util.WSProxy();<br>  //================== https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/accountuser.html<br>  var cols = [&quot;Name&quot;,&quot;CustomerKey&quot;,&quot;NotificationEmailAddress&quot;, &quot;UserID&quot;, &quot;ActiveFlag&quot;, &quot;Email&quot;, &quot;IsAPIUser&quot;, &quot;AccountUserID&quot;, &quot;LastSuccessfulLogin&quot;, &quot;CreatedDate&quot;, &quot;Roles&quot;];<br>  //================= https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/ssjs_WSProxy_basic_retrieve.html<br>  var filter = {<br>    LeftOperand: {Property: &quot;Email&quot;,SimpleOperator: &quot;like&quot;,Value: &quot;@&quot;},<br>    LogicalOperator: &quot;AND&quot;,<br>    RightOperand: {Property: &quot;ActiveFlag&quot;,SimpleOperator: &quot;equals&quot;,Value: &quot;true&quot;}<br>  };<br>  var res = prox.retrieve(&quot;AccountUser&quot;, cols, filter);<br>  Write(Stringify(res.Results)+&quot;&lt;br&gt;&lt;br&gt;&lt;br&gt;&quot;);<br><br>    Write(&quot;&lt;table border=1&gt;&lt;tr&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Email&lt;/th&gt;&lt;th&gt;CreatedDate&lt;/th&gt;&lt;th&gt;LastSuccessfulLogin&lt;/th&gt;&lt;th&gt;Roles&lt;/th&gt;&lt;/tr&gt;&quot;);<br>    for (i = 0; i &lt; res.Results.length; i++) {<br>      Write(&quot;&lt;tr&gt;&lt;td&gt;&quot; + res.Results[i].Name + &quot;&lt;/td&gt;&lt;td&gt;&quot; + res.Results[i].Email + &quot;&lt;/td&gt;&lt;td&gt;&quot; + res.Results[i].CreatedDate + &quot;&lt;/td&gt;&lt;td&gt;&quot; + res.Results[i].LastSuccessfulLogin + &quot;&lt;/td&gt;&lt;td&gt;&quot;);<br>      for (r = 0; r &lt; res.Results[i].Roles.length; r++) {<br>        Write(res.Results[i].Roles[r].Name + &quot;&lt;br&gt;&quot;);<br>      }<br>    Write(&quot;&lt;/td&gt;&lt;/tr&gt;&quot;);<br>    }<br>  Write(&quot;&lt;/table&gt;&quot;); <br>  }<br>catch(error) {<br>  Write(&#39;Message: &#39; + error);<br>}<br>&lt;/script&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72c9012cc8fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SFMC opening data extensions]]></title>
            <link>https://jake-borromeo.medium.com/sfmc-opening-data-extensions-38364111b8ae?source=rss-446fbab18de1------2</link>
            <guid isPermaLink="false">https://medium.com/p/38364111b8ae</guid>
            <dc:creator><![CDATA[Jake Borromeo]]></dc:creator>
            <pubDate>Tue, 28 Feb 2023 22:42:30 GMT</pubDate>
            <atom:updated>2023-02-28T22:50:14.508Z</atom:updated>
            <content:encoded><![CDATA[<pre>&lt;script runat=&quot;server&quot;&gt;<br>Platform.Load(&quot;core&quot;,&quot;1.1.5&quot;);<br><br>var url = &quot;https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com/interaction/v1/interactions/YOUR_JOURNEY_ID/history&quot;;<br>var auth = {<br>    &quot;ClientId&quot;: &quot;YOUR_CLIENT_ID&quot;,<br>    &quot;ClientSecret&quot;: &quot;YOUR_CLIENT_SECRET&quot;,<br>    &quot;RefreshToken&quot;: &quot;YOUR_REFRESH_TOKEN&quot;<br>};<br>var payload = {<br>    &quot;startDate&quot;: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString(),<br>    &quot;endDate&quot;: new Date().toISOString(),<br>    &quot;attributes&quot;: [&quot;EventDate&quot;,&quot;ContactKey&quot;,&quot;ContactID&quot;,&quot;InteractionID&quot;,&quot;ActivityID&quot;,&quot;DefinitionID&quot;,&quot;DefinitionKey&quot;,&quot;EventType&quot;,&quot;BatchID&quot;,&quot;SubscriberKey&quot;,&quot;IsInsideFilter&quot;,&quot;PathID&quot;,&quot;VersionNumber&quot;,&quot;Duration&quot;,&quot;DeviceID&quot;,&quot;Channel&quot;],<br>    &quot;pageSize&quot;: 1000,<br>    &quot;pageNumber&quot;: 1<br>};<br><br>var response = HTTP.Post(url, &#39;application/json&#39;, Stringify(payload), auth);<br><br>if (response.StatusCode == 200) {<br>    var results = Platform.Function.ParseJSON(response.Response[0]);<br>    // Do something with the results, like display them on a CloudPage<br>} else {<br>    // Handle error<br>}<br>&lt;/script&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38364111b8ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving ‘Two Sum’ LeetCode Problem]]></title>
            <link>https://jake-borromeo.medium.com/solving-two-sum-leetcode-problem-87dc75a1353?source=rss-446fbab18de1------2</link>
            <guid isPermaLink="false">https://medium.com/p/87dc75a1353</guid>
            <dc:creator><![CDATA[Jake Borromeo]]></dc:creator>
            <pubDate>Sat, 31 Dec 2022 05:32:36 GMT</pubDate>
            <atom:updated>2022-12-31T05:32:36.446Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rk2HjrGqmzOiYSYu" /><figcaption>Photo by <a href="https://unsplash.com/@cdr6934?utm_source=medium&amp;utm_medium=referral">Chris Ried</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Are you feeling stuck on the Two Sum Leetcode problem? Don’t worry, we’ve all been there. But fear not, for I am here to guide you through the solution and make the journey as enjoyable as possible.</p><p>First things first, let’s go over the problem statement:</p><p>Given an array of integers, return indices of the two numbers such that they add up to a specific target.</p><p>You may assume that each input would have exactly one solution, and you may not use the same element twice.</p><p>Got it? Great! Now let’s break down the problem and see how we can solve it.</p><p>One way to solve this problem is to use a brute force approach, where we loop through the array and check every combination of numbers to see if they add up to the target. However, this would result in a time complexity of O(n²), which is not ideal for larger arrays.</p><p>Instead, we can use a more efficient approach that has a time complexity of O(n). To do this, we can use a hash map to store the numbers we’ve seen so far. As we loop through the array, we can check if the target minus the current number is in the map. If it is, we’ve found our solution.</p><p>Here’s the code for this solution:</p><pre>Copy code</pre><pre>function twoSum(nums, target) {<br>  const map = new Map();<br>  for (let i = 0; i &lt; nums.length; i++) {<br>    if (map.has(target - nums[i])) {<br>      return [map.get(target - nums[i]), i];<br>    }<br>    map.set(nums[i], i);<br>  }<br>  return [];<br>}</pre><p>In this code, we create a new Map object and store it in the map variable. Then, we loop through the nums array and check if the target minus the current number is in the map. If it is, we return the indices of the two numbers that add up to the target. If not, we add the current number to the map with its index as the value.</p><p>By using this approach, we are able to solve the Two Sum problem in O(n) time, which is much more efficient than the O(n²) brute force approach.</p><p>And there you have it! A solution to the Two Sum problem that is both efficient and easy to understand.</p><p>Now, go forth and conquer Leetcode! And remember, with a little bit of humor and a positive attitude, any problem can be solved. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87dc75a1353" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Cookies: A Comprehensive Guide to Storing Data with Cookies]]></title>
            <link>https://jake-borromeo.medium.com/react-cookies-a-comprehensive-guide-to-storing-data-with-cookies-4c297270467b?source=rss-446fbab18de1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c297270467b</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[cookies]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jake Borromeo]]></dc:creator>
            <pubDate>Wed, 28 Dec 2022 01:04:37 GMT</pubDate>
            <atom:updated>2022-12-28T02:16:51.606Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aXaGmwlgAHJwZXpepSi4mA.jpeg" /><figcaption><a href="https://www.thehansindia.com/hans/opinion/">https://www.thehansindia.com/hans</a></figcaption></figure><p>Cookies are a simple and effective way to store data on the client-side of a web application. They allow you to store small pieces of information that can be accessed by the server or client-side scripts, making them a useful tool for storing user preferences, tracking user sessions, and more.</p><p>But how do you use cookies with React, and when should you choose cookies over other storage options like web storage or local storage? In this article, we’ll explore these questions and more as we dive into the world of cookies with React.</p><h3>What you can do with Cookies</h3><p>Cookies are a common feature of web applications, and they can be very useful for storing small pieces of information on the client side. Before we look at how to leverage cookies, let’s check out some of the common use cases for cookies:</p><ol><li><strong>Storing user preferences: </strong>Cookies can be used to store user preferences such as the language or theme of a web application. This allows users to customize their experience and have their preferences persist across multiple visits.</li><li><strong>Persisting user sessions: </strong>Cookies can be used to store session information, allowing users to remain logged in to a web application even after closing their browser. This can be particularly useful for applications that require a high level of security, such as financial or healthcare applications.</li><li><strong>Tracking user activity: </strong>Cookies can be used to track user activity, such as the pages they visit or the products they view on an e-commerce website. This information can be used to personalize the user experience, show targeted advertisements, or analyze user behavior.</li><li><strong>Implementing authentication:</strong> Cookies can be used to implement authentication in a web application. When a user logs in, a cookie containing their authentication information can be set, and this cookie can be checked on subsequent requests to determine if the user is logged in.</li><li><strong>Enabling third-party integration: </strong>Cookies can be used to enable integration with third-party services, such as social media networks or analytics tools. By storing information in a cookie, these services can track user activity and provide additional functionality to your application.</li></ol><h3>How Cookies actually work</h3><p>Cookies are small pieces of data that are stored in the user’s browser and can be accessed by the server or client-side scripts. They are typically used to store user preferences, track user sessions, and store small amounts of data.</p><p>Cookies are stored in the form of key-value pairs, with the key being the name of the cookie and the value being the data stored in the cookie. Cookies are sent to the server with every HTTP request and can be accessed by the server or client-side scripts using the document.cookie property.</p><p>Cookies have a number of attributes that can be set to control their behavior. These attributes include:</p><ul><li>expires: The date at which the cookie expires and is deleted from the user&#39;s browser.</li><li>max-age: The maximum age of the cookie in seconds.</li><li>path: The path on the server to which the cookie is sent.</li><li>secure: A flag indicating whether the cookie should only be sent over secure connections.</li><li>httpOnly: A flag indicating whether the cookie should only be accessed by the server.</li></ul><h3>Using Cookies in React</h3><p>So how do you use cookies in a React application? There are a few different approaches you can take, but one of the simplest is to use the js-cookie library. This library provides a simple API for reading, writing, and deleting cookies in your React components.</p><p>To use js-cookie in your React application, you&#39;ll need to install the library first:</p><pre>npm install js-cookie</pre><p>Once the library is installed, you can import it into your React components and use its methods to read, write, and delete cookies. Here’s an example of how to use js-cookie to read a cookie in a React component:</p><pre>import Cookies from &#39;js-cookie&#39;;</pre><pre>function MyComponent() {<br>  const name = Cookies.get(&#39;name&#39;);</pre><pre>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;Your name is: {name}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In this example, the Cookies.get method is used to read the name cookie from the user&#39;s browser. The value of the cookie is then displayed in a paragraph element.</p><p>You can also use the Cookies.set method to write a cookie in a React component:</p><pre>import Cookies from &#39;js-cookie&#39;;</pre><pre>function MyComponent() {<br>  const [name, setName] = useState(Cookies.get(&#39;name&#39;) || &#39;&#39;);</pre><pre>  const handleChange = e =&gt; {<br>    setName(e.target.value);<br>  };</pre><pre>  const handleSubmit = e =&gt; {<br>    e.preventDefault();<br>    Cookies.set(&#39;name&#39;, name);<br>  };</pre><pre>  return (<br>    &lt;form onSubmit={handleSubmit}&gt;<br>      &lt;input value={name} onChange={handleChange} /&gt;<br>      &lt;button type=&quot;submit&quot;&gt;Save&lt;/button&gt;<br>    &lt;/form&gt;<br>  );<br>}</pre><p>In this example, the Cookies.set method is used to write the name cookie to the user&#39;s browser when the form is submitted. The name value is stored in the cookie with a default expiration date of one year.</p><p>You can also use the Cookies.remove method to delete a cookie in a React component:</p><pre>import Cookies from &#39;js-cookie&#39;;</pre><pre>function MyComponent() {<br>  const handleClick = () =&gt; {<br>    Cookies.remove(&#39;name&#39;);<br>  };</pre><pre>  return (<br>    &lt;button onClick={handleClick}&gt;Clear&lt;/button&gt;<br>  );<br>}</pre><p>In this example, the Cookies.remove method is used to delete the name cookie from the user&#39;s browser when the button is clicked.</p><p>It’s important to note that cookies have size limits and can only store strings. If you need to store large amounts of data or data of other types, you may need to use a different storage option such as local storage or a database.</p><h3>Choosing Between Cookies, Web Storage, and Local Storage</h3><p>So now that you know how to use cookies with React, how do you choose between cookies, web storage, and local storage? Here are a few factors to consider:</p><ul><li><strong>Scope:</strong> Cookies are sent to the server with every HTTP request, making them a useful tool for storing data that needs to be accessed by the server. Web storage and local storage, on the other hand, are stored on the client-side and are not sent to the server with HTTP requests.</li><li><strong>Lifetime: </strong>Cookies can have an expiration date or a maximum age set, while web storage and local storage are persistent. Choose cookies if you need to store data for aspecific period of time, and choose web storage or local storage if you need to store data indefinitely.</li><li><strong>Size: </strong>Cookies have a maximum size of around 4KB, while web storage and local storage have larger limits of around 5MB and 10MB, respectively. Choose cookies if you only need to store small amounts of data, and choose web storage or local storage if you need to store larger amounts of data.</li><li><strong>Security</strong>: Cookies are sent to the server with every HTTP request and are stored on the client-side, making them less secure than web storage and local storage. If you need to store sensitive data, it’s best to use web storage or local storage.</li></ul><h3>Wrapping Up</h3><p>Cookies are a powerful tool for storing small pieces of information on the client side and can be used in a variety of ways in a React application. Whether you’re looking to store user preferences, persist user sessions, track user activity, implement authentication, or enable third-party integration, cookies can be a useful addition to your toolkit.</p><p>We hope this comprehensive guide to cookies with React has given you a better understanding of how to use cookies in your applications. With the power of cookies at your fingertips, you’ll be able to create user-friendly and functional React applications that will delight your users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c297270467b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Web Storage with React: A Guide to Session and Local Storage]]></title>
            <link>https://jake-borromeo.medium.com/mastering-web-storage-with-react-a-comprehensive-guide-to-session-and-local-storage-2171d7ea2e3b?source=rss-446fbab18de1------2</link>
            <guid isPermaLink="false">https://medium.com/p/2171d7ea2e3b</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[localstorage]]></category>
            <category><![CDATA[usememo]]></category>
            <dc:creator><![CDATA[Jake Borromeo]]></dc:creator>
            <pubDate>Wed, 28 Dec 2022 00:44:06 GMT</pubDate>
            <atom:updated>2022-12-28T00:57:59.759Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oL1EEwnnEmZOdY--iAHa_g.jpeg" /><figcaption>image: <a href="https://res.cloudinary.com/de4rvmslk/image/upload/w_2000/f_auto,q_auto//img/LocalStorage-cover_photo.png">https://res.cloudinary.com/de4rvmslk/image</a></figcaption></figure><p>Are you looking to improve the user experience and functionality of your React applications? Look no further than web storage! Web storage allows you to store data on the client-side, making it easy to save user preferences, cache data, and more.</p><p>But with two types of storage to choose from — session storage and local storage — it can be tough to know which one to use and when. And how do you integrate web storage with React? In this article, we’ll explore these questions and more as we dive into the world of web storage with React.</p><h3>What is Web Storage?</h3><p>Web storage is a way to store data on the client-side of a web application. It allows you to save data that persists beyond a single page load, making it a useful tool for storing user preferences, cache data, and more.</p><p>There are two types of web storage: session storage and local storage. Both types of storage allow you to store data as key-value pairs, but they differ in their scope and lifetime.</p><p>Session storage is specific to a single browser tab or window and is deleted when the tab or window is closed. This makes it a useful tool for storing temporary data that is only needed within a single session.</p><p>Local storage, on the other hand, is persistent and is not deleted when the tab or window is closed. This makes it a useful tool for storing data that needs to be available across multiple sessions.</p><h3>Using Web Storage in React</h3><p>So how do you use web storage in a React application? The window.sessionStorage and window.localStorage objects provide methods for storing and retrieving data from web storage.</p><p>To use web storage in a React component, you can access these objects directly or create a wrapper function to handle the storage and retrieval of data. Here’s an example of a wrapper function for session storage:</p><pre>const useSessionStorage = (key, initialValue) =&gt; {<br>  const [value, setValue] = useState(<br>    () =&gt; window.sessionStorage.getItem(key) || initialValue<br>  );</pre><pre>  useEffect(() =&gt; {<br>    window.sessionStorage.setItem(key, value);<br>  }, [key, value]);</pre><pre>  return [value, setValue];<br>};</pre><p>This wrapper function uses the useState and useEffect hooks to store and retrieve data from session storage. The function takes a key and an initialValue as arguments and returns an array with the current value and a function to update the value.</p><p>To use this wrapper function in a component, you can call it like any other hook:</p><pre>function MyComponent() {<br>  const [name, setName] = useSessionStorage(&#39;name&#39;, &#39;Bob&#39;);<br>  return ( &lt;div&gt; &lt;input value={name} onChange={e =&gt; setName(e.target.value)} /&gt; &lt;p&gt;Your name is: {name}&lt;/p&gt; &lt;/div&gt; ); <br>}</pre><p>In this example, the component uses the `useSessionStorage` wrapper function to store and retrieve the value of an input field in session storage. The value is saved to session storage when the input field is changed and is retrieved from session storage when the component is rendered.</p><p>You can use a similar wrapper function for local storage, or you can use the `window.localStorage` object directly. Here’s an example of how to use local storage in a React component:</p><pre>function MyComponent() {<br>  const [name, setName] = useState(window.localStorage.getItem(&#39;name&#39;) || &#39;Bob&#39;);</pre><pre>  useEffect(() =&gt; {<br>    window.localStorage.setItem(&#39;name&#39;, name);<br>  }, [name]);</pre><pre>  return (<br>    &lt;div&gt;<br>      &lt;input value={name} onChange={e =&gt; setName(e.target.value)} /&gt;<br>      &lt;p&gt;Your name is: {name}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In this example, the component uses the useState and useEffect hooks to store and retrieve the value of an input field in local storage. The value is saved to local storage when the input field is changed and is retrieved from local storage when the component is rendered.</p><p>It’s important to note that web storage has limitations on the size and type of data that can be stored. Session storage has a limit of around 5MB, while local storage has a limit of around 10MB. Both types of storage can only store strings, so you’ll need to convert other data types to strings before storing them.</p><h3>Choosing Between Session and Local Storage</h3><p>So now that you know how to use web storage in React, how do you choose between session storage and local storage? Here are a few factors to consider:</p><ul><li>Lifetime: As mentioned earlier, session storage is deleted when the tab or window is closed, while local storage is persistent. Choose session storage if you only need to store data for a single session, and choose local storage if you need to store data across multiple sessions.</li><li>Security: Local storage is stored on the client-side and is not sent to the server with HTTP requests, making it less secure than session storage. If you need to store sensitive data, it’s best to use session storage.</li><li>Size: Both session storage and local storage have limits on the size of data that can be stored. If you need to store large amounts of data, you may need to use a different solution such as a database or a cloud storage service.</li></ul><h3>Wrapping Up</h3><p>We hope this comprehensive guide to web storage with React has given you a better understanding of how to use session storage and local storage in your applications. With the power of web storage at your fingertips, you’ll be able to create user-friendly and functional React applications that will delight your users. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2171d7ea2e3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maximizing Performance with useMemo: A Deep Dive into React’s Memoization Hook]]></title>
            <link>https://jake-borromeo.medium.com/maximizing-performance-with-usememo-a-deep-dive-into-reacts-memoization-hook-a61b40136eee?source=rss-446fbab18de1------2</link>
            <guid isPermaLink="false">https://medium.com/p/a61b40136eee</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[usememo]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[hooks]]></category>
            <dc:creator><![CDATA[Jake Borromeo]]></dc:creator>
            <pubDate>Wed, 28 Dec 2022 00:32:28 GMT</pubDate>
            <atom:updated>2022-12-28T00:32:28.057Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uQM9mG3dmaA0dPNxoK8ydg.jpeg" /><figcaption>illustration by: <a href="https://enmascript.com/">https://enmascript.com/</a></figcaption></figure><p>Are you looking to boost the performance of your React applications? Look no further than the useMemo hook! This powerful tool allows you to optimize the performance of your components by caching the results of expensive calculations.</p><p>But what exactly is memoization and how does it work? And how can you use the useMemo hook to improve the performance of your React components? In this article, we&#39;ll explore these questions and more as we dive deep into the world of memoization with React.</p><h3>What is Memoization?</h3><p>At its core, memoization is a technique for improving the performance of a function by storing the results of expensive calculations and returning the cached result when the function is called with the same arguments. This can significantly reduce the number of times the function has to be called, saving time and resources.</p><p>Here’s an example of a simple function that calculates the nth Fibonacci number using a recursive approach:</p><pre>function fib(n) {<br>  if (n &lt; 2) {<br>    return n;<br>  }<br>  return fib(n - 1) + fib(n - 2);<br>}</pre><p>While this function works fine for small values of n, it becomes very slow for larger values due to the recursive nature of the calculation. For example, calculating the 50th Fibonacci number takes a significant amount of time and resources.</p><p>To optimize this function using memoization, we can create a cache object to store the results of the calculations and check if the result is already in the cache before calling the function:</p><pre>function fib(n) {<br>  if (n in cache) {<br>    return cache[n];<br>  }<br>  if (n &lt; 2) {<br>    return n;<br>  }<br>  const result = fib(n - 1) + fib(n - 2);<br>  cache[n] = result;<br>  return result;<br>}</pre><p>Now, when we call the fib function with a value of n that has already been calculated, the result is returned from the cache rather than being recalculated. This significantly improves the performance of the function, especially for larger values of n.</p><h3>Using the useMemo Hook in React</h3><p>So how does all of this relate to React? Well, the useMemo hook is a way to apply memoization to the values used in your React components. It allows you to cache the results of expensive calculations and avoid unnecessary re-renders of your components.</p><p>To use the useMemo hook, you pass in a function that calculates the value you want to memoize and an array of dependencies. The hook will then return the cached value and only recalculate it if one of the dependencies has changed.</p><p>Here’s an example of how you can use the useMemo hook to optimize the performance of a component that displays a list of items:</p><pre>import { useMemo } from &#39;react&#39;;</pre><pre>function ItemList({ items }) {<br>  const sortedItems = useMemo(() =&gt; {<br>    return items.sort((a, b) =&gt; a.name.localeCompare(b.name));<br>  }, [items]);</pre><pre>  return (<br>    &lt;ul&gt;<br>      {sortedItems.map(item =&gt; (<br>        &lt;li key={item.id}&gt;{item.name}&lt;/li&gt;<br>      ))}<br>    &lt;/ul&gt;<br>  );<br>}</pre><p>In this example, the useMemo hook is used to sort the items array and cache the result. The items array is passed as a dependency to the hook, so the sorting function will only be called if the items array changes. This helps to avoid unnecessary re-renders of the component and improve its performance.</p><h3>Things to Consider</h3><p>It’s important to note that the useMemo hook should be used sparingly and only for expensive calculations that are necessary for the component to function correctly. Overuse of the hook can lead to poor performance and increased complexity.</p><p>Another important thing to consider is the order in which the hook is called. The useMemo hook is called during the rendering phase of the component, so it&#39;s important to make sure that the hook is called after any updates tothe component’s state or props. For example, if you have a component that updates its state in an onClick handler, you should call the useMemo hook after the update rather than before it:</p><pre>import { useState, useMemo } from &#39;react&#39;;</pre><pre>function MyComponent() {<br>  const [count, setCount] = useState(0);<br>  const doubleCount = useMemo(() =&gt; count * 2, [count]);</pre><pre>  return (<br>    &lt;div&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Increment&lt;/button&gt;<br>      &lt;p&gt;{doubleCount}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In this example, the useMemo hook is called after the setCount function is called, ensuring that the doubleCount value is updated correctly.</p><h3>Wrapping Up</h3><p>We hope this deep dive into the useMemo hook has given you a better understanding of how memoization can be used to improve the performance of your React components. Remember to use the hook sparingly and only for expensive calculations, and pay attention to the order in which it is called to avoid unexpected behavior.</p><p>With the power of memoization at your fingertips, you’ll be able to create lightning-fast React applications that will wow your users and impress your colleagues. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a61b40136eee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to React Portals]]></title>
            <link>https://jake-borromeo.medium.com/introduction-to-react-portals-5f81d347794c?source=rss-446fbab18de1------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f81d347794c</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javasc]]></category>
            <category><![CDATA[portal]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jake Borromeo]]></dc:creator>
            <pubDate>Tue, 27 Dec 2022 05:41:39 GMT</pubDate>
            <atom:updated>2022-12-27T05:41:39.233Z</atom:updated>
            <content:encoded><![CDATA[<p>React portals are a powerful tool that allows you to render a React component outside of its parent component. This can be useful in a variety of situations, such as:</p><ul><li>Creating modals or dialogs</li><li>Adding notifications or alerts</li><li>Rendering elements in a different DOM context, such as in the &lt;head&gt; of the document</li></ul><p>To use portals, you’ll need to install the react-dom package:</p><pre>npm install react-dom</pre><p>Then, you can use the ReactDOM.createPortal() method to create a portal. This method takes two arguments: the element to be rendered and the DOM element where the element should be rendered.</p><p>Here’s an example of a simple portal that renders a modal:</p><pre>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;</pre><pre>function Modal() {<br>  return ReactDOM.createPortal(<br>    &lt;div className=&quot;modal&quot;&gt;<br>      &lt;p&gt;This is a modal&lt;/p&gt;<br>    &lt;/div&gt;,<br>    document.body<br>  );<br>}</pre><p>In this example, the Modal component is rendered in the &lt;body&gt; of the document, outside of its parent component.</p><h3>Using Portals with State</h3><p>To use portals with state, you’ll need to create a container component that manages the state and renders the portal. Here’s an example of a ModalContainer component that controls the visibility of the modal:</p><pre>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;</pre><pre>function Modal({ isOpen }) {<br>  return ReactDOM.createPortal(<br>    &lt;div className={`modal ${isOpen ? &#39;is-open&#39; : &#39;&#39;}`}&gt;<br>      &lt;p&gt;This is a modal&lt;/p&gt;<br>    &lt;/div&gt;,<br>    document.body<br>  );<br>}</pre><pre>import React, { useState } from &#39;react&#39;;<br>import Modal from &#39;./Modal&#39;;</pre><pre>function ModalContainer() {<br>  const [isOpen, setIsOpen] = useState(false);</pre><pre>  return (<br>    &lt;&gt;<br>      &lt;button onClick={() =&gt; setIsOpen(true)}&gt;Open Modal&lt;/button&gt;<br>      &lt;Modal isOpen={isOpen} /&gt;<br>    &lt;/&gt;<br>  );<br>}</pre><p>In this example, the ModalContainer component manages the isOpen state, which determines whether the modal is visible or not. When the user clicks the &quot;Open Modal&quot; button, the isOpen state is set to true, which causes the modal to be displayed.</p><h3>Closing the Modal</h3><p>To close the modal, you’ll need to add a way for the user to dismiss it. Here’s an example of a Modal component that includes a close button:</p><pre>import React, { useState } from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;</pre><pre>function Modal({ isOpen, onClose }) {<br>  return ReactDOM.createPortal(<br>    &lt;div className={`modal ${isOpen ? &#39;is-open&#39; : &#39;&#39;}`}&gt;<br>      &lt;button onClick={onClose}&gt;Close&lt;/button&gt;<br>      &lt;p&gt;This is a modal&lt;/p&gt;<br>    &lt;/div&gt;,<br>    document.body<br>  );<br>}</pre><pre>function ModalContainer() {<br>  const [isOpen, setIsOpen] = useState(false);</pre><pre>  function handleClose() {<br>    setIsOpen(false);<br>  }</pre><pre>  return (<br>    &lt;&gt;<br>      &lt;button onClick={() =&gt; setIsOpen(true)}&gt;Open Modal&lt;/button&gt;<br>      &lt;Modal isOpen={isOpen} onClose={handleClose} /&gt;<br>    &lt;/&gt;<br>  );<br>}</pre><p>In this example, the Modal component includes a close button that calls the onClose prop when clicked. The ModalContainer component passes a handleClose function to the Modal component as the onClose prop, which sets the isOpen state to false and hides the modal.</p><h3>Advanced Techniques</h3><p>Here are a few advanced techniques for using portals:</p><h3>Accessing the Portal Node</h3><p>If you need to access the DOM node of the portal, you can use the ref prop:</p><pre>import React, { useRef } from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;</pre><pre>function Modal({ isOpen }) {<br>  const modalRef = useRef();</pre><pre>  return ReactDOM.createPortal(<br>    &lt;div className={`modal ${isOpen ? &#39;is-open&#39; : &#39;&#39;}`} ref={modalRef}&gt;<br>      &lt;p&gt;This is a modal&lt;/p&gt;<br>    &lt;/div&gt;,<br>    document.body<br>  );<br>}</pre><p>In this example, the modalRef ref is attached to the &lt;div&gt; element that is being rendered as a portal. You can access the DOM node of the portal using the current property of the ref:</p><pre>console.log(modalRef.current); // The DOM node of the portal</pre><h3>Updating the Portal Element</h3><p>If you need to update the element being rendered in the portal, you can use the ReactDOM.unstable_renderSubtreeIntoContainer() method. This method allows you to update the element being rendered in the portal without unmounting and remounting the portal component.</p><p>Here’s an example of a Modal component that uses the unstable_renderSubtreeIntoContainer() method to update the element being rendered in the portal:</p><pre>import React, { useEffect, useRef } from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;</pre><pre>function Modal({ isOpen, children }) {<br>  const modalRef = useRef();<br>  const portalElement = useRef();</pre><pre>  useEffect(() =&gt; {<br>    portalElement.current = document.createElement(&#39;div&#39;);<br>    document.body.appendChild(portalElement.current);</pre><pre>    return () =&gt; {<br>      document.body.removeChild(portalElement.current);<br>    };<br>  }, []);</pre><pre>  useEffect(() =&gt; {<br>    ReactDOM.unstable_renderSubtreeIntoContainer(<br>      modalRef.current,<br>      &lt;div className={`modal ${isOpen ? &#39;is-open&#39; : &#39;&#39;}`}&gt;<br>        &lt;button onClick={onClose}&gt;Close&lt;/button&gt;<br>        {children}<br>      &lt;/div&gt;,<br>      portalElement.current<br>    );<br>  }, [isOpen, children]);</pre><pre>  return ReactDOM.createPortal(<br>    &lt;div ref={modalRef} /&gt;,<br>    portalElement.current<br>  );<br>}</pre><p>In this example, the Modal component uses the useEffect() hook to create a new DOM element when the component is mounted, and to remove the element when the component is unmounted. The unstable_renderSubtreeIntoContainer() method is used to update the element being rendered in the portal when the isOpen prop or the children prop changes.</p><h3>Handling Keyboard Events</h3><p>If you’re using portals to create modals or dialogs, you’ll likely want to handle keyboard events to allow the user to close the modal using the Escape key. Here&#39;s an example of a Modal component that handles keyboard events:</p><pre>import React, { useEffect, useRef } from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;</pre><pre>function Modal({ isOpen, onClose }) {<br>  const modalRef = useRef();<br>  const portalElement = useRef();</pre><pre>  useEffect(() =&gt; {<br>    portalElement.current = document.createElement(&#39;div&#39;);<br>    document.body.appendChild(portalElement.current);</pre><pre>    return () =&gt; {<br>      document.body.removeChild(portalElement.current);<br>    };<br>  }, []);</pre><pre>  useEffect(() =&gt; {<br>    const handleKeyDown = (event) =&gt; {<br>      if (event.key === &#39;Escape&#39;) {<br>        onClose();<br>      }<br>    };</pre><pre>    document.addEventListener(&#39;keydown&#39;, handleKeyDown);</pre><pre>    return () =&gt; {<br>      document.removeEventListener(&#39;keydown&#39;, handleKeyDown);<br>    };<br>  }, [onClose]);</pre><pre>  useEffect(() =&gt; {<br>    ReactDOM.unstable_renderSubtreeIntoContainer(</pre><pre>import React, { useEffect, useRef } from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;</pre><pre>function Modal({ isOpen, onClose }) {<br>  const modalRef = useRef();<br>  const portalElement = useRef();</pre><pre>  useEffect(() =&gt; {<br>    portalElement.current = document.createElement(&#39;div&#39;);<br>    document.body.appendChild(portalElement.current);</pre><pre>    return () =&gt; {<br>      document.body.removeChild(portalElement.current);<br>    };<br>  }, []);</pre><pre>  useEffect(() =&gt; {<br>    const handleKeyDown = (event) =&gt; {<br>      if (event.key === &#39;Escape&#39;) {<br>        onClose();<br>      }<br>    };</pre><pre>    document.addEventListener(&#39;keydown&#39;, handleKeyDown);</pre><pre>    return () =&gt; {<br>      document.removeEventListener(&#39;keydown&#39;, handleKeyDown);<br>    };<br>  }, [onClose]);</pre><pre>  useEffect(() =&gt; {<br>    ReactDOM.unstable_renderSubtreeIntoContainer(<br>      modalRef.current,<br>      &lt;div className={`modal ${isOpen ? &#39;is-open&#39; : &#39;&#39;}`}&gt;<br>        &lt;button onClick={onClose}&gt;Close&lt;/button&gt;<br>        &lt;p&gt;This is a modal&lt;/p&gt;<br>      &lt;/div&gt;,<br>      portalElement.current<br>    );<br>  }, [isOpen]);</pre><pre>  return ReactDOM.createPortal(<br>    &lt;div ref={modalRef} /&gt;,<br>    portalElement.current<br>  );<br>}</pre><pre>function ModalContainer() {<br>  const [isOpen, setIsOpen] = useState(false);</pre><pre>  function handleOpen() {<br>    setIsOpen(true);<br>  }</pre><pre>  function handleClose() {<br>    setIsOpen(false);<br>  }</pre><pre>  return (<br>    &lt;&gt;<br>      &lt;button onClick={handleOpen}&gt;Open Modal&lt;/button&gt;<br>      &lt;Modal isOpen={isOpen} onClose={handleClose}</pre><h3>Wrapping Up</h3><p>React portals are a powerful tool that can be used in a variety of situations to render elements outside of their parent component. They’re especially useful for creating modals, dialogs, and notifications, and can be easily integrated into your React app with just a few lines of code.</p><p>I hope this article has helped you understand how portals work and how to use them effectively in your own projects. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f81d347794c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a Search Bar for your SFMC UI]]></title>
            <link>https://jake-borromeo.medium.com/create-a-search-bar-for-your-sfmc-ui-b3445611c71d?source=rss-446fbab18de1------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3445611c71d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[marketing-cloud]]></category>
            <category><![CDATA[sfmc]]></category>
            <dc:creator><![CDATA[Jake Borromeo]]></dc:creator>
            <pubDate>Tue, 27 Dec 2022 02:25:11 GMT</pubDate>
            <atom:updated>2022-12-27T02:25:11.704Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vFp43KQhzH91baui" /><figcaption>Photo by <a href="https://unsplash.com/fr/@rocinante_11?utm_source=medium&amp;utm_medium=referral">Mick Haupt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Are you tired of combing through folders and BUs to find automations, content, or data extensions in Salesforce Marketing Cloud? Look no further! In this tutorial, we will walk you through the steps to build a Chrome extension that adds that allows users to search for to the Salesforce Marketing Cloud UI. With just a few clicks, you’ll be able to search and selct all data extensions in your account with ease. Whether you’re a developer or simply looking to streamline your workflow, this extension is a must-have tool. Let’s get started!</p><p>To create a Chrome extension that adds a search bar to the Salesforce Marketing Cloud UI, you will need to do the following:</p><ol><li>Create a new directory for your extension and create a manifest.json file. This file contains metadata about your extension, including its name and permissions.</li><li>Add a permission for the Salesforce Marketing Cloud UI to your manifest.json file:</li></ol><pre>&quot;permissions&quot;: [<br>    &quot;https://*.s1.marketingcloudapps.com/*&quot;<br>]</pre><p>3. Create an HTML file that will contain your search bar. This file should have a form element with an input field and a submit button.</p><p>4. Create a JavaScript file that will handle the search functionality. This file should listen for the form’s submit event and send a request to the Salesforce Marketing Cloud API to search for data extensions, automations, and journeys based on the text entered in the input field.</p><p>5. Use the Chrome Extension API to inject your HTML and JavaScript files into the Salesforce Marketing Cloud UI when the extension is activated. Test your extension to make sure it works as expected.</p><p>Here is some example code for the manifest.json, HTML, and JavaScript files:</p><pre>{<br>  &quot;manifest_version&quot;: 2,<br>  &quot;name&quot;: &quot;Salesforce Marketing Cloud Search&quot;,<br>  &quot;version&quot;: &quot;1.0&quot;,<br>  &quot;permissions&quot;: [<br>    &quot;https://*.s1.marketingcloudapps.com/*&quot;<br>  ],<br>  &quot;content_scripts&quot;: [<br>    {<br>      &quot;matches&quot;: [&quot;https://*.s1.marketingcloudapps.com/*&quot;],<br>      &quot;css&quot;: [&quot;style.css&quot;],<br>      &quot;js&quot;: [&quot;search.js&quot;],<br>      &quot;run_at&quot;: &quot;document_idle&quot;<br>    }<br>  ]<br>}</pre><p>The search bar should be able to locate data extensions, automations, and journeys based on text entered into the search bar. add detailed coding examples and snippets. Here is an example of the HTML file that contains the search bar:</p><pre>&lt;form id=&quot;search-form&quot;&gt;<br>  &lt;input type=&quot;text&quot; id=&quot;search-input&quot; placeholder=&quot;Search data extensions, automations, and journeys&quot;&gt;<br>  &lt;button type=&quot;submit&quot;&gt;Search&lt;/button&gt;<br>&lt;/form&gt;</pre><p>And here is an example of the JavaScript file that handles the search functionality:</p><pre>const form = document.getElementById(&quot;search-form&quot;);<br>const input = document.getElementById(&quot;search-input&quot;);<br><br>form.addEventListener(&quot;submit&quot;, event =&gt; {<br>  event.preventDefault();<br><br>  const searchText = input.value;<br><br>  // Send a request to the Salesforce Marketing Cloud API to search for data extensions, automations, and journeys based on the search text<br>  // The API endpoint and required headers will depend on your specific setup<br>  fetch(&quot;https://api.s1.marketingcloudapps.com/search&quot;, {<br>    method: &quot;POST&quot;,<br>    headers: {<br>      &quot;Content-Type&quot;: &quot;application/json&quot;,<br>      &quot;Authorization&quot;: &quot;Bearer YOUR_ACCESS_TOKEN&quot;<br>    },<br>    body: JSON.stringify({<br>      searchText<br>    })<br>  })<br>  .then(response =&gt; response.json())<br>  .then(results =&gt; {<br>    // Process the search results and display them in the UI<br>  })<br>  .catch(error =&gt; {<br>    console.error(error);<br>  });<br>});</pre><p>Finally, you can use the Chrome Extension API to inject your HTML and JavaScript files into the Salesforce Marketing Cloud UI when the extension is activated. Here is an example of how to do this in your background script:</p><pre>chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) =&gt; {<br>  if (changeInfo.status === &quot;complete&quot; &amp;&amp; tab.url.startsWith(&quot;https://*.s1.marketingcloudapps.com/&quot;)) {<br>    chrome.tabs.executeScript(tabId, {<br>      file: &quot;deselect.js&quot;<br>    });<br>    chrome.tabs.insertCSS(tabId, {<br>      file: &quot;style.css&quot;<br>    });<br>  }<br>});</pre><p>To display the search results in the UI, you can use the results returned by the Salesforce Marketing Cloud API and render them in the HTML file. Here is an example of how you might do this:</p><pre>&lt;div id=&quot;search-results&quot;&gt;<br>  &lt;!-- Render the search results here --&gt;<br>&lt;/div&gt;</pre><pre>// Process the search results and display them in the UI<br>const searchResultsContainer = document.getElementById(&quot;search-results&quot;);<br>searchResultsContainer.innerHTML = &quot;&quot;;<br><br>results.forEach(result =&gt; {<br>  const resultElement = document.createElement(&quot;div&quot;);<br>  resultElement.innerHTML = `&lt;h2&gt;${result.name}&lt;/h2&gt;&lt;p&gt;${result.description}&lt;/p&gt;`;<br>  searchResultsContainer.appendChild(resultElement);<br>});</pre><p>You can also style the search bar and search results using CSS in the style.css file.</p><p>Remember to test your extension to make sure it works as expected. You can do this by installing the extension in Chrome and navigating to the Salesforce Marketing Cloud UI. When you enter text in the search bar and submit the form, the extension should send a request to the API and display the search results in the UI.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3445611c71d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[6 Advanced React Techniques to Boost Your TypeScript Skills]]></title>
            <link>https://jake-borromeo.medium.com/6-advanced-react-techniques-to-boost-your-typescript-skills-eedd24b0543?source=rss-446fbab18de1------2</link>
            <guid isPermaLink="false">https://medium.com/p/eedd24b0543</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Jake Borromeo]]></dc:creator>
            <pubDate>Tue, 27 Dec 2022 02:06:54 GMT</pubDate>
            <atom:updated>2022-12-27T02:06:54.405Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gJTXIPG4jASRtiZv" /><figcaption>Photo by <a href="https://unsplash.com/@lautaroandreani?utm_source=medium&amp;utm_medium=referral">Lautaro Andreani</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Are you ready to take your React and TypeScript skills to the next level? Look no further! In this article, we’ll explore some advanced techniques that will help you build more powerful and scalable apps with these powerful technologies.</p><h3>1. Strongly-typed redux with TypeScript</h3><p>One of the key benefits of using TypeScript with React is the ability to define strong types for your redux store and actions. This can help catch bugs and make your code more maintainable in the long run.</p><p>Here’s an example of how you can define a strongly-typed reducer and action creators in TypeScript:</p><pre>import { Action, ActionCreator, Reducer } from &quot;redux&quot;<br><br>// Define the action types as constants<br>export const INCREMENT = &quot;INCREMENT&quot;<br>export const DECREMENT = &quot;DECREMENT&quot;<br><br>// Define the action interfaces<br>interface IncrementAction extends Action {<br>  type: typeof INCREMENT<br>}<br><br>interface DecrementAction extends Action {<br>  type: typeof DECREMENT<br>}<br><br>// Define the combined action type<br>type CounterAction = IncrementAction | DecrementAction<br><br>// Define the action creators<br>export const increment: ActionCreator&lt;IncrementAction&gt; = () =&gt; ({<br>  type: INCREMENT<br>})<br><br>export const decrement: ActionCreator&lt;DecrementAction&gt; = () =&gt; ({<br>  type: DECREMENT<br>})<br><br>// Define the initial state<br>export interface CounterState {<br>  count: number<br>}<br><br>const initialState: CounterState = {<br>  count: 0<br>}<br><br>// Define the reducer<br>export const counterReducer: Reducer&lt;CounterState, CounterAction&gt; = (<br>  state = initialState,<br>  action<br>) =&gt; {<br>  switch (action.type) {<br>    case INCREMENT:<br>      return { ...state, count: state.count + 1 }<br>    case DECREMENT:<br>      return { ...state, count: state.count - 1 }<br>    default:<br>      return state<br>  }<br>}</pre><h3>2. Async actions with redux-thunk and TypeScript</h3><p>Sometimes you need to perform async operations in your redux actions, like fetching data from an API. That’s where redux-thunk comes in handy. It allows you to write action creators that return functions instead of plain objects, which can dispatch multiple actions and perform async logic.</p><p>Here’s an example of how you can use redux-thunk with TypeScript to fetch data from an API and update the store:</p><pre>import { ActionCreator, Dispatch } from &quot;redux&quot;<br>import { ThunkAction } from &quot;redux-thunk&quot;<br>import { getData } from &quot;./api&quot;<br><br>// Define the action types as constants<br>export const REQUEST_DATA = &quot;REQUEST_DATA&quot;<br>export const RECEIVE_DATA = &quot;RECEIVE_DATA&quot;<br>export const RECEIVE_ERROR = &quot;RECEIVE_ERROR&quot;<br><br>// Define the action interfaces<br>interface RequestDataAction extends Action {<br>  type: typeof REQUEST_DATA<br>}<br><br>interface ReceiveDataAction extends Action {<br>  type: typeof RECEIVE_DATA<br>  data: any<br>}<br><br>interface ReceiveErrorAction extends Action {<br>  type: typeof RECEIVE_ERROR<br>  error</pre><h3>3. Render props with TypeScript</h3><p>Render props is a technique in React where a component renders a prop that is a function. This can be useful for sharing logic between components without having to use higher-order components (HOCs) or props drilling.</p><p>Here’s an example of how you can use render props with TypeScript:</p><pre>import React from &quot;react&quot;<br><br>interface MouseProps {<br>  render: (state: { x: number, y: number }) =&gt; React.ReactNode<br>}<br><br>class Mouse extends React.Component&lt;MouseProps&gt; {<br>  state = { x: 0, y: 0 }<br><br>  handleMouseMove = (event: React.MouseEvent&lt;HTMLDivElement&gt;) =&gt; {<br>    this.setState({<br>      x: event.clientX,<br>      y: event.clientY<br>    })<br>  }<br><br>  render() {<br>    return (<br>      &lt;div style={{ height: &quot;100vh&quot; }} onMouseMove={this.handleMouseMove}&gt;<br>        {this.props.render(this.state)}<br>      &lt;/div&gt;<br>    )<br>  }<br>}<br><br>const App = () =&gt; (<br>  &lt;Mouse<br>    render={({ x, y }) =&gt; (<br>      &lt;h1&gt;The mouse position is ({x}, {y})&lt;/h1&gt;<br>    )}<br>  /&gt;<br>)</pre><h3>4. Higher-order components (HOCs) with TypeScript</h3><p>Higher-order components (HOCs) are functions that take a component and return a new component with additional functionality. They can be useful for abstracting common logic or injecting props into a component.</p><p>Here’s an example of how you can use HOCs with TypeScript to add a simple loading indicator to a component:</p><pre>import React from &quot;react&quot;<br><br>interface InjectedProps {<br>  isLoading: boolean<br>}<br><br>const withLoadingIndicator = &lt;P extends object&gt;(<br>  WrappedComponent: React.ComponentType&lt;P&gt;<br>) =&gt; {<br>  type Props = P &amp; InjectedProps<br><br>  class WithLoadingIndicator extends React.Component&lt;Props&gt; {<br>    render() {<br>      const { isLoading, ...rest } = this.props as InjectedProps<br><br>      if (isLoading) {<br>        return &lt;h1&gt;Loading...&lt;/h1&gt;<br>      }<br><br>      return &lt;WrappedComponent {...rest as P} /&gt;<br>    }<br>  }<br><br>  return WithLoadingIndicator<br>}<br><br>interface DataProps {<br>  data: any<br>}<br><br>const DataComponent = (props: DataProps) =&gt; &lt;h1&gt;{props.data}&lt;/h1&gt;<br><br>const EnhancedDataComponent = withLoadingIndicator(DataComponent)<br><br>const App = () =&gt; (<br>  &lt;EnhancedDataComponent data={&quot;Hello World&quot;} isLoading={false} /&gt;<br>)</pre><h3>5. TypeScript decorators</h3><p>Decorators is a feature in TypeScript that allows you to annotate and modify classes and their members. They can be useful for adding additional functionality or metadata to your code.</p><h3>6. TypeScript and React Hooks</h3><p>React Hooks is a feature in React that allows you to use state and other React features without writing a class component. They can be used with TypeScript by annotating the types of the hook variables.</p><p>Here’s an example of how you can use the useState hook with TypeScript:</p><pre>import React, { useState } from &quot;react&quot;<br><br>interface FormState {<br>  name: string<br>  email: string<br>}<br><br>const Form = () =&gt; {<br>  const [formState, setFormState] = useState&lt;FormState&gt;({<br>    name: &quot;&quot;,<br>    email: &quot;&quot;<br>  })<br><br>  const handleChange = (event: React.ChangeEvent&lt;HTMLInputElement&gt;) =&gt; {<br>    const { name, value } = event.target<br>    setFormState({ ...formState, [name]: value })<br>  }<br><br>  return (<br>    &lt;form&gt;<br>      &lt;label htmlFor=&quot;name&quot;&gt;Name:&lt;/label&gt;<br>      &lt;input<br>        type=&quot;text&quot;<br>        id=&quot;name&quot;<br>        name=&quot;name&quot;<br>        value={formState.name}<br>        onChange={handleChange}<br>      /&gt;<br>      &lt;br /&gt;<br>      &lt;label htmlFor=&quot;email&quot;&gt;Email:&lt;/label&gt;<br>      &lt;input<br>        type=&quot;email&quot;<br>        id=&quot;email&quot;<br>        name=&quot;email&quot;<br>        value={formState.email}<br>        onChange={handleChange}<br>      /&gt;<br>    &lt;/form&gt;<br>  )<br>}</pre><p>There you have it, 6 advanced techniques for using React and TypeScript together to build powerful and scalable applications. Whether you’re a seasoned pro or a newcomer to these technologies, we hope you learned something new and can put these techniques to good use in your own projects. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eedd24b0543" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock the Power of SFMC Roles and Permissions — Here’s How]]></title>
            <link>https://jake-borromeo.medium.com/unlock-the-power-of-sfmc-roles-and-permissions-heres-how-ef95fdc17870?source=rss-446fbab18de1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef95fdc17870</guid>
            <category><![CDATA[sfmc-admin-certification]]></category>
            <category><![CDATA[sfmc]]></category>
            <category><![CDATA[marketing-cloud]]></category>
            <category><![CDATA[sfmc-admin-cert]]></category>
            <category><![CDATA[roles-and-permissions]]></category>
            <dc:creator><![CDATA[Jake Borromeo]]></dc:creator>
            <pubDate>Mon, 26 Dec 2022 23:52:20 GMT</pubDate>
            <atom:updated>2022-12-26T23:52:20.242Z</atom:updated>
            <content:encoded><![CDATA[<h3>Unlock the Power of SFMC Roles and Permissions — Here’s How</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2cvpVdk0tkcrK2Ps" /><figcaption>Photo by <a href="https://unsplash.com/es/@flyd2069?utm_source=medium&amp;utm_medium=referral">FLY:D</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Are you ready to dive into the world of marketing cloud roles and become a certified pro? Great — because in this article, we’re going to cover everything you need to know about marketing cloud roles to ace the SFMC Administrator certification exam. So put on your thinking cap, grab a cup of coffee, and let’s get started!</p><p>First things first — what exactly are marketing cloud roles? Simply put, marketing cloud roles are a way to control access to different features and functions within your SFMC account. By assigning specific roles to users, you can ensure that they have the appropriate level of access to perform their job duties, while also protecting sensitive information and data.</p><h4>So why are marketing cloud roles important? There are a few key reasons:</h4><p><strong><em>Control access:</em> </strong>Marketing cloud roles provide a way to control access to different features and functions within your SFMC account. This can be especially useful if you have multiple people working on your account, as it ensures that each user only has access to the tools and resources they need to perform their job duties.</p><p><strong><em>Protect sensitive information: </em></strong>Marketing cloud roles also help to protect sensitive information and data within your SFMC account. By restricting access to certain features or functions, you can ensure that only authorized users have access to sensitive information, such as customer data or financial records.</p><p><strong><em>Streamline workflows: </em></strong>Marketing cloud roles can also help to streamline workflows and make it easier for users to perform their job duties. By assigning specific roles to users, you can ensure that they have the tools and resources they need to do their job efficiently and effectively.</p><p>So what are the different marketing cloud roles and permissions available in SFMC? Here’s a quick overview:</p><ol><li>Full Access: Users with the Full Access role have complete access to all features and functions within your SFMC account. This includes the ability to create and edit campaigns, import and export data, and access sensitive information.</li><li>Account User: Users with the Account User role have access to most features and functions within your SFMC account, but are restricted from certain tasks, such as importing and exporting data or accessing sensitive information.</li><li>Email User: Users with the Email User role have limited access to SFMC, with a focus on creating and sending email campaigns. This role does not include access to data imports or exports, or sensitive information.</li><li>Marketing Cloud Connect User: Users with the Marketing Cloud Connect User role have access to SFMC Connect, which allows them to integrate SFMC with Salesforce CRM. This role does not include access to other features or functions within SFMC.</li><li>Read Only: Users with the Read Only role have limited access to SFMC, with the ability to view campaigns and reports but not create or edit them. This role does not include access to data imports or exports, or sensitive information.</li></ol><p>So how do you use marketing cloud roles in SFMC? Here are a few key things to keep in mind:</p><h4>Assign roles to users.</h4><p>To use marketing cloud roles, you’ll need to assign specific roles to users within your SFMC account. This can be done by going to the “User Management” tab and selecting “Roles.” From here, you can create new roles or edit existing ones as needed.</p><h4>Set permissions for each role.</h4><p>Once you’ve created your marketing cloud roles, you’ll need to set permissions for each role by specifying which features and functions each role has access to, as well as any additional restrictions or limitations. You can set permissions by going to the “User Management” tab and selecting “Permissions.”</p><h4>Test and review.</h4><p>Once you’ve set up your marketing cloud roles and permissions, it’s important to test them out and review them regularly to ensure that they’re working as expected. This may involve assigning different roles to different users and testing their access to different features and functions, as well as reviewing the logs and reports to identify any issues or problems that may arise.</p><p>Marketing cloud roles are a crucial tool for controlling access, protecting sensitive information, and streamlining workflows in SFMC. By assigning roles to users, setting permissions, and reviewing them regularly, you can ensure that your SFMC account is running smoothly and efficiently. So go ahead and put your new-found knowledge to the test — we have no doubt that you’ll be a SFMC role master in no time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef95fdc17870" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>