Using the fill prop in Next Image but the images are not showing

I’m mapping the images to display them. I’m using fill prop of Next Image but the images are not showing in the browser. It’s showing the moment I use width and height props.
I could have gone with the height and width props but that doesn’t help in maintaining consistent dimensions for the images.

I’m not getting what’s the issue

Here’s the code:

<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
  {japandiImages.map((image, index) => (
    <div key={index} className="relative w-full h-64">
      <Image
        src={image.src}
        alt={image.alt}
        fill
        sizes="(max-width: 768px) 100vw, (max-width: 1200px) 33vw, 33vw"
        className="object-cover rounded-lg shadow"
      />
    </div>
  ))}
</div>

Here’s the link to the GitHub repo in case you wanna see the whole code. The problem is in the route folder named Japandi:
Link to the repo

  1. I tried using width and height props of Next Image and it works. However, I can’t use them because they make the dimensions inconsistent for the images.

  2. On some YT video, they say to use sizes props along with fill. I tried that too, but it’s still not working.

Magento error on static-content:deploy -f

I’m getting this error Unexpected input in styles-l-temp.less

frontend/Pearl/weltpixel/en_US          2964/3067           ===========================> 96% %   3 secs
Compilation from source: /opt/bitnami/apps/magento/htdocs/app/design/frontend/Pearl/weltpixel/web/css/styles-l-temp.less
ParseError: Unexpected input in styles-l-temp.less on line 1, column 1
1| #@import '../WeltPixel_FrontendOptions/css/source/module/_store_completehome_extend.less';
2|
3|


  [MagentoFrameworkExceptionFileSystemException]
  Cannot read contents from file "/opt/bitnami/apps/magento/htdocs/pub/static/frontend/Pearl/weltpixel/en_US/c
  ss/styles-l-temp.css" Warning!file_get_contents(/opt/bitnami/apps/magento/htdocs/pub/static/frontend/Pearl/w
  eltpixel/en_US/css/styles-l-temp.css): failed to open stream: No such file or directory

So, i remove the #@import to @import and execute these commands:

sudo rm -rf /opt/bitnami/apps/magento/htdocs/var/cache/*
sudo rm -rf /opt/bitnami/apps/magento/htdocs/var/page_cache/*
sudo rm -rf /opt/bitnami/apps/magento/htdocs/var/view_preprocessed/*
sudo rm -rf /opt/bitnami/apps/magento/htdocs/pub/static/frontend/*

Now, when execute static-content:deploy -f command is shows this error:

bitnami@ip-172-26-13-233:/opt/bitnami/apps/magento/htdocs$ sudo /opt/bitnami/apps/magento/htdocs/bin/magento-cli setup:static-content:deploy -f

Deploy using quick strategy
frontend/Magento/blank/en_US            3037/3037           ============================ 100% %  3 secs          frontend/Magento/blank/en_US            3037/3037           ============================ 100% %  3 secs          frontend/Magento/blank/en_US            3037/3037           ============================ 100% %  3 secs          
frontend/Magento/blank/en_US            3037/3037           ============================ 100% %  3 secs          
frontend/Magento/blank/en_US            3037/3037           ============================ 100% %  3 secs          
frontend/Magento/blank/en_US            3037/3037           ============================ 100% %  3 secs          
frontend/Magento/blank/en_US            3037/3037           ============================ 100% %  3 secs          
adminhtml/Magento/backend/en_US         2383/2383           ============================ 100% %  2 secs          frontend/Magento/blank/en_US            3037/3037           ============================ 100% %  3 secs          
adminhtml/Magento/backend/en_US         2383/2383           ============================ 100% %  2 secs          frontend/Magento/blank/en_US            3037/3037           ============================ 100% %  3 secs          
adminhtml/Magento/backend/en_US         2383/2383           ============================ 100% %  2 secs          
frontend/Magento/luma/en_US             3053/3053           ============================ 100% %  4 secs          
frontend/Pearl/weltpixel/en_US          2951/3067           ==========================>- 96% %   3 secs
#0 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/App/View/Asset/Publisher.php(73): MagentoFrameworkViewAssetFile->getSourceFile()
#1 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/App/View/Asset/Publisher.php(61): MagentoFrameworkAppViewAssetPublisher->publishAsset(Object(MagentoFrameworkViewAssetFile))
#2 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-deploy/Service/DeployStaticFile.php(89): MagentoFrameworkAppViewAssetPublisher->publish(Object(MagentoFrameworkViewAssetFile))
#3 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-deploy/Service/DeployPackage.php(189): MagentoDeployServiceDeployStaticFile->deployFile('css/styles-l-te...', Array)
#4 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-deploy/Service/DeployPackage.php(136): MagentoDeployServiceDeployPackage->processFile(Object(MagentoDeployPackagePackageFile), Object(MagentoDeployPackagePackage))
#5 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-deploy/Service/DeployPackage.php(107): MagentoDeployServiceDeployPackage->deployEmulated(Object(MagentoDeployPackagePackage), Array, false)
#6 [internal function]: MagentoDeployServiceDeployPackage->MagentoDeployService{closure}()
#7 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/App/State.php(186): call_user_func_array(Object(Closure), Array)
#8 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-deploy/Service/DeployPackage.php(108): MagentoFrameworkAppState->emulateAreaCode('frontend', Object(Closure))
#9 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-deploy/Process/Queue.php(300): MagentoDeployServiceDeployPackage->deploy(Object(MagentoDeployPackagePackage), Array)
#10 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-deploy/Process/Queue.php(219): MagentoDeployProcessQueue->execute(Object(MagentoDeployPackagePackage))
#11 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-deploy/Process/Queue.php(162): MagentoDeployProcessQueue->assertAndExecute('frontend/Pearl/...', Array, Array)
#12 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-deploy/Strategy/QuickDeploy.php(76): MagentoDeployProcessQueue->process()
#13 /opt/bitnami/apps/magento/htdocs/vendor/magento/module-deploy/Service/DeployStaticContent.php(109): MagentoDeployStrategyQuickDeploy->deploy(Array)
#14 /opt/bitnami/apps/magento/htdocs/setup/src/Magento/Setup/Console/Command/DeployStaticContentCommand.php(140): MagentoDeployServiceDeployStaticContent->deploy(Array)
#15 /opt/bitnami/apps/magento/htdocs/vendor/symfony/console/Command/Command.php(241): MagentoSetupConsoleCommandDeployStaticContentCommand->execute(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#16 /opt/bitnami/apps/magento/htdocs/vendor/symfony/console/Application.php(844): SymfonyComponentConsoleCommandCommand->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#17 /opt/bitnami/apps/magento/htdocs/vendor/symfony/console/Application.php(193): SymfonyComponentConsoleApplication->doRunCommand(Object(MagentoSetupConsoleCommandDeployStaticContentCommand), Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#18 /opt/bitnami/apps/magento/htdocs/vendor/magento/framework/Console/Cli.php(104): SymfonyComponentConsoleApplication->doRun(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#19 /opt/bitnami/apps/magento/htdocs/vendor/symfony/console/Application.php(117): MagentoFrameworkConsoleCli->doRun(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#20 /opt/bitnami/apps/magento/htdocs/bin/magento(30): SymfonyComponentConsoleApplication->run()
#21 {main}


  [MagentoFrameworkExceptionFileSystemException]
  Cannot read contents from file "/opt/bitnami/apps/magento/htdocs/pub/static/frontend/Pearl/weltpixel/en_US/c
  ss/styles-l-temp.css" Warning!file_get_contents(/opt/bitnami/apps/magento/htdocs/pub/static/frontend/Pearl/w
  eltpixel/en_US/css/styles-l-temp.css): failed to open stream: No such file or directory


setup:static-content:deploy [-f|--force] [-s|--strategy [STRATEGY]] [-a|--area [AREA]] [--exclude-area [EXCLUDE-AREA]] [-t|--theme [THEME]] [--exclude-theme [EXCLUDE-THEME]] [-l|--language [LANGUAGE]] [--exclude-language [EXCLUDE-LANGUAGE]] [-j|--jobs [JOBS]] [--symlink-locale] [--content-version CONTENT-VERSION] [--refresh-content-version-only] [--no-javascript] [--no-css] [--no-less] [--no-images] [--no-fonts] [--no-html] [--no-misc] [--no-html-minify] [--] [<languages>]...

I was trying to add another store with a subdomain. The domain completehome.completeattire.com was created, and the issue occurred when I started the service.

How to create a plugin to “Ensure all French translations from the theme .po files are imported into the Polylang database automatically” [closed]

HI I am working on a creating of a plugin where site is built using child of a classic theme

where I need to Ensure all French translations from the theme .po files are imported into the Polylang database automatically

Current status:I Manual conversion of _()/e() to pll()/pll_e() in the theme is done and working.

So Now i my requirement is to Create a one-time plugin to import existing .po translations into Polylang GUI/database.

The Purpose of it is to Avoid manual entry errors, reduce deployment downtime, and ensure translations work correctly in live/production.

Scope: Use existing .pot, .po, .mo files from the theme. No additional files are required. in my wp-contents/Language contain the theme and plugin folders where the all .po, .mo files are present

so on enabling this plugin all French translations must be verified and confirmed functional before task completion.

Also English strings may appear on French pages if the import is not done properly. The plugin is single-use, not continuous.

Why is there no newline being presented here?

I wrote the following bit of code to read through a passed in email stream (or .eml file while I’m testing).

During the test, it’s supposed to read through each line of a stream but it seems it’s just outputting as one line, even thouhg there is a newline in the stream.

My code is as follows:

function sendMailForward($email) {
    // Load recipients from ENV (comma-separated list)
    $newRecipients = preg_split("/,s*/", $_ENV['ADMIN_EMAIL'] ?? '', -1, PREG_SPLIT_NO_EMPTY);

    // For StackOverflow: This passes in a comma-separated list of emails, this line is not part of the problem.

    $raw_email = "";
    while (!feof($email)) {
        $raw_email .= fread($email, 1024);
    }
    fclose($email);

    // Extract headers for a clean subject and sender
    $headers = [];
    $lines = explode("n", $raw_email); // This line, somehow, doesn't see newlines in the stream.
    foreach ($lines as $line) {
        echo "New line!n"; // This was me trying to test and what should show up multiple times, only shows up once.
        if (strpos($line, ":") !== false) {
            $parts = explode(":", $line, 2);
            $key = trim($parts[0]);
            $value = trim($parts[1]);
            $headers[$key] = $value;
        }
        // Stop at the first blank line, which marks the end of headers
        if (trim($line) == "") {
            break;
        }
    }

    $original_subject = isset($headers['Subject']) ? "FWD: " . $headers['Subject'] : "FWD: No Subject";
    $original_from = isset($headers['From']) ? $headers['From'] : "unknown sender";

    $subject = $original_subject;
    $message = "--- Original message from $original_from ---nn" . $raw_email;
    $extra_headers = "From: [email protected]"; // Customize 'From' address


    foreach ($newRecipients as $recipient) {
        $to = $recipient;
        // Send the email
        mail($to, $subject, $message, $extra_headers);
    }
}

What should I change in the above code? Should I force a newline to be appended? Or is there something else happening that I should be aware of.

(If it also helps, the rest of the email is non-existent too.)

Per request below. This is the email I’m using to test.


From: "Megan at TCGplayer" <[email protected]>
To: "TCGPlayer Account" <[email protected]>
Subject: Test Email for Forwarding
Date: Sat, 28 Sep 2025 08:00:00 -0400
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit

Hello,

This is a test email to verify the mail forwarding module.

Best regards,
Test System

EDIT 2: Someone asked for how is the code being used.

// Read original message from stdin
$rawEmail = file_get_contents('php://stdin');

sendMailForward($rawEmail);

Simply put just invoking it.

my wordpress site gets a 500 error that keeps coming back [closed]

I am hosting a website and every now and then I get the 500 error on the website.
I went through all of it:

  • checking permissions and chmoding
  • removing the .htaccess and rewriting it
  • disabling plugins (i only have the acf plugin )

when i fix the error, it comes back the next day without me even touching the files :/

My cshtml table cant be populated dynamically by the javascript api call

I recently started learning web development with netcore 8 and i simply want to make a table with CRUD. Im using existing resources on SSMS for the database. But I cant even get the table to be populated.

The table inside my Index.cshtml:

     <!-- Table -->
     <div class="table-responsive">
         <table id="userTable" class="table table-striped table-bordered align-middle">
             <thead class="table-light">
                 <tr>
                     <th>Employee ID</th>
                     <th>Name</th>
                     <th>Role</th>
                     <th>Department</th>
                     <th>Date Created</th>
                     <th style="width: 100px;">Aksi</th>
                 </tr>
             </thead>
             <tbody></tbody> <!-- populated by UserManagement.js-->
         </table>
     </div>

     <!-- Pagination -->
     <nav aria-label="User table pagination">
         <ul class="pagination justify-content-end">
             <li class="page-item disabled"><a class="page-link">«</a></li>
             <li class="page-item active"><a class="page-link" href="#">1</a></li>
             <li class="page-item"><a class="page-link" href="#">2</a></li>
             <li class="page-item"><a class="page-link" href="#">3</a></li>
             <li class="page-item"><a class="page-link" href="#">»</a></li>
         </ul>
     </nav>
 </div>
<!-- ApiBaseUrl is "https://localhost:7043/api/", its originated from "ApiSettings" inside appsettings.json -->
 <script> const API_BASE_URL = '@ViewBag.ApiBaseUrl';</script>

<!-- chatgpt told me to use this, previously i used src="~js/UserManagement.js", but it doesnt work, I put the script inside wwwrooot/js/UserManagement.js-->
<script src="@Url.Content("~/js/UserManagement.js")" asp-append-version="true"></script>

My UserManagement.js:

console.log("JS loaded, API_BASE_URL =", API_BASE_URL);
//I desperately want to see any output that suggest this script is loaded, so you will see a bunch of these, but Console tab in DevTools is totally empty.

document.addEventListener("DOMContentLoaded", function () {
    loadUsers();
    document.querySelector("#btnSearch").addEventListener("click", function () {
        const keyword = document.querySelector("#txtSearch").value;
        loadUsers(1, keyword);
    });
});

// this is the function that should populate the table

function loadUsers(page = 1, search = "") {
    const url = `${API_BASE_URL}Users?page=${page}&pageSize=10&search=${encodeURIComponent(search)}`;
    console.log("Fetching:", url);
    fetch(url)
        .then(response => response.json())
        .then(result => {
            const tbody = document.querySelector("#userTable tbody");
            tbody.innerHTML = "";

            result.users.forEach(user => {
                const row = `
                    <tr>
                        <td>${user.employeeId ?? "-"}</td>
                        <td>${user.name ?? "-"}</td>
                        <td>${user.roleName ?? "-"}</td>
                        <td>${user.dept}</td>
                        <td>${formatDate(user.createDate)}</td>
                        <td>
                            <button class="btn btn-sm btn-light"><i class="si si-pencil"></i></button>
                            <button class="btn btn-sm btn-light text-danger"><i class="si si-trash"></i></button>
                        </td>
                    </tr>`;
                tbody.insertAdjacentHTML("beforeend", row);
            });
        })
        .catch(error => console.error("Error fetching users:", error));
}

function formatDate(dateStr) {
    const date = new Date(dateStr);
    return date.toLocaleString("id-ID", {
        day: "2-digit",
        month: "long",
        year: "numeric",
        hour: "2-digit",
        minute: "2-digit"
    });
}

document.addEventListener("DOMContentLoaded", () => {
    consol.log("DOM fully loaded and parsed");
    loadUsers();
});
console.log("Script loaded");

my UserManagementController.cs:

using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using MyTableApp.Config;

namespace MyTableApp.Controllers
{
    public class UserManagementController : Controller
    {
        readonly ApiSettings _apiSettings;

        public UserManagementController(IOptions<ApiSettings> apiSettings)
        {
            _apiSettings = apiSettings.Value;
        }

        public IActionResult Index()
        {
            ViewBag.ApiBaseUrl = _apiSettings.BaseUrl;
            return View();
        }
    }
}

and lastly, my UsersController.cs

using Microsoft.AspNetCore.Mvc;
using MyTableApi.Models.Entities.DB_FOR_LEARNING_NET8;

namespace MyTableApi.Controllers
{
    [ApiController]
    [Route("api/[controller]")]
    public class UsersController : ControllerBase
    {
        readonly DbForLearningNet8Context _context;

        public UsersController(DbForLearningNet8 context)
        {
            _context = context;
        }

        [HttpGet]
        public IActionResult GetUsers(
            int page = 1,
            int pageSize = 10,
            string? search = null)
        {
            var query = _context.VwEmployeeDetails.AsQueryable();

            if(!string.IsNullOrWhiteSpace(search))
            {
                query = query.Where(u => u.EmployeeID.Contains(search) || u.Name.Contains(search));
            }

            var totalUsers = query.Count();

            var users = query
                .OrderByDescending(u => u.CreateDate)
                .Skip((page - 1) * pageSize)
                .Take(pageSize)
                .ToList();

            return Ok(new
            {
                totalUsers,
                page,
                pageSize,
                users
            });
        }
    }
}

So when I try to run the api and web app project, the table is empty. Nothing inside of Console on DevTools. The only references to UserManagement.js I can find inside Network tab is this UserManagement.js?v=”some_random_string” with the status 200 and Users?page=1&pageSize=10&search= with the status 404 (fetch).

Im sorry if I send too many codes, I have been trying to fix this for hours and yet nothing seems to fix it, it makes no sense to me as how is it showing that it was able to reference UserManagement.js but not a single console.log is printed in the Console tab?
I appreciate any kind of help or knowledge about Net Core 8!

Why does URL Pattern API accept wildcard at the beginning of pathname?

The pathname URL-part always starts with /. If you omit the / in your regular expression the match will fail

URL Pattern API (pathname matching)

Let leading slash be true if the first code point in value is U+002F (/) and otherwise false

WHATWG (canonicalize a pathname)

The pathname options is an options struct with delimiter code point set “/” and prefix code point set to “/”

WHATWG (pathname options)

Why is the output true if the string doesn’t start with “/”?

console.log(
  new URLPattern({pathname: '*/books'}).test({pathname: '/api/v1/books'})
)

Is it a hidden feature or did I miss some point in MDN or in WHATWG?

How can I include the file name (or origin) where a function is executed?

I have event bus for mFEs and i want to add filename to each dispatched object to know from where dispatched event comes.

i have solution which looks ugly, in dispatch function every time create Error and find it’s origin:

const err = new Error();
if (!err.stack) {
    return {};
}

const callerLine = err.stack.split("n")[3];

is there better way to do it without writing filename in each file?

How to safely capture both toast title and message in Playwright without waiting timeout?

I’m working with Playwright (Node.js) and need to capture notification toasts that appear on the page.
The issue is that the toasts don’t always have the same structure:

  • Some have only a message

  • Some have a title and a message

  • They also change their class (toast-info, toast-warning, toast-error, etc.)

When I try to capture both the title and the message, Playwright sometimes freezes, waiting for .toast-title when it doesn’t exist. I need a safe and generic way to capture all possible cases without running into timeouts.

<!-- example of toast with only message -->
<div id="toast-container" class="toast-top-right" aria-live="polite" role="alert">
  <div class="toast toast-info" style="display: block;">
    <button class="toast-close-button" role="button"><i class="ion-android-close"></i></button>
    <div class="toast-message">Nota Lesión Activa: Lesiones 364</div>
  </div>
</div>

<!-- example of toast with title and message -->
<div id="toast-container" class="toast-top-right" aria-live="polite" role="alert">
  <div class="toast toast-error" style="display: block;">
    <button class="toast-close-button" role="button"><i class="ion-android-close"></i></button>
    <div class="toast-title">Error</div>
    <div class="toast-message">Paciente no encontrado</div>
  </div>
</div>

Error observed

Sometimes my test fails with a timeout when trying to get the toast title:

Get text content(
page.locator('#toast-container .toast').first().locator('.toast-title')
)
— 30.0s
waiting for locator('#toast-container .toast').first().locator('.toast-title')
Timeout 30000ms exceeded.

What I tried

I created two functions: one (boton) that clicks a button and checks for toasts, and another (Capturaerror) that extracts the toast-title and toast-message.

async function boton(page, Accion, indice = 0) {
    await page.getByRole('button', { name: Accion }).nth(indice).click({ timeout: 1000 });
    const toasts = page.locator('#toast-container .toast, #toast-container .toast-error, #toast-container .toast-warning');
    const count = await toasts.count();
    const mensajes = [];

    for (let i = 0; i < count; i++) {
        const toast = toasts.nth(i);
        const clase = await toast.getAttribute('class') || '';
        const mensaje = await toast.locator('.toast-message').textContent().catch(() => '');

        if (clase.includes('toast-error')) {
            if (mensaje && mensaje.trim() !== '') {
                mensajes.push(`${i + 1}.- ${mensaje.trim()}`);
            }
        } else if (clase.includes('toast-warning')) {
            const msj = await Capturaerror(page);
            if (msj && msj.length > 0) {
                throw new Error(`${msj.join('n')}`);
            }
        } 
    }

    if (mensajes.length > 0) {
        throw new Error(mensajes.join("n"));
    }
}

async function Capturaerror(page) {
    const toasts = await page.locator('#toast-container .toast').all();
    const mensajes = [];

    let index = 1;
    for (const toast of toasts) {
        const titulo = await toast.locator('.toast-title').textContent().catch(() => '');
        const mensaje = await toast.locator('.toast-message').textContent().catch(() => '');
        if (titulo || mensaje) {
            mensajes.push(`${index}.- ${titulo.trim()}: ${mensaje.trim()}`);
            index++;
        }            
    }
    return mensajes;
}

What I expected

To always capture the visible text of each toast, regardless of whether it has a title, a message, or both.
The .catch(() => '') should skip missing .toast-title without freezing.


What actually happens

If a toast does not contain a .toast-title, Playwright waits for it until the timeout (30s), which causes the test to freeze.


Notes

  • I want a single generic solution that safely captures the title and/or message, or the whole toast text, without timeouts.

  • Node.js / Playwright environment.

usememo hook and usecallback hook

where to use usememo hook and usecallback hooks

Explanation for the Usememo and usecallback hooks and their usage and main differences between these hooks because this hooks are using for the similar usage (memoization).

LIFF getIDToken returns undefined on iOS but works on Android

I am building an application with Java Spring Boot + Jquery using LiffSDK for my chat application.

  @GetMapping
  public String init(@RequestParam String liffChannelId,
      @RequestParam String messageChannelId,
      @RequestParam String isInit,
      @RequestParam String idToken,
      HttpServletRequest request, Model model) {
    if (Objects.isNull(isInit)) {
      return "chat_ui";
    }

    ChatForm form =chatHelper.init(liffChannelId, messageChannelId, idToken, request);
    model.addAttribute("form", form);

    return "chat_ui";
  }

And in my Js:

$(document).ready(function () {
  const urlParams = new URLSearchParams(window.location.search);
  const isInit = urlParams.get("isInit");
  if (!isInit) {
    initLiffApp();
  }
});

function initLiffApp() {
  const messageChannelId = new URLSearchParams(window.location.search).get("messageChannelId");

  const liffChannelId = new URLSearchParams(window.location.search).get("liffChannelId");

  const liffId = new URLSearchParams(window.location.search).get("liffId");

  liff
    .init({
      liffId: liffId
    })
    .then(() => {
      const idToken = liff.getIDToken();
      if (!idToken) {
        alert("Failed to get ID Token");
        return;
      }
      sendToServer(liffChannelId, messageChannelId, idToken);
    })
    .catch(err => {
      console.error("LIFF error", err);
    });
}

function sendToServer(liffChannelId, messageChannelId, idToken) {
  const redirectUrl = `/chat?liffChannelId=${encodeURIComponent(liffChannelId)}&messageChannelId=${encodeURIComponent(messageChannelId)}&isInit=1&idToken=${encodeURIComponent(idToken)}`;
  window.location.href = redirectUrl;
}

The application being deployed will call the server twice. When initializing, based on whether the isInit variable is passed or not, it will return to the interface. Then in Js, it will call Liff Server to get idToken. At this time, it will call the server a second time with the isInit variable = true and then the server will continue processing.

I tested on Android and it still received normally, but on iOS it kept saying it could not get idToken and displayed an alert cannot get idToken.

Can someone help me with this problem? Thank you very much

Triggering onClick() and keyup() automatically when using an onscreen keyboards

I have two virtual key boards codes for two languages other than English. The codes are working perfectly and values of pressed keys transferred to respective input text boxes, The only problem is that functions of keyup() and OnClick() do not work until and unless enter key from manual keyboard is pressed or mouse click done into the input box. Will appreciate if following codes are amended to include in them keyup() and Click() functions, so there should be no need to manually touch any key from manual keyboard or mouse clicked into the text box. thanks.

<input type="text"  id="myInput" onkeyup="myFunction()" onClick="myFunction()" placeholder=>

//First virtual keyboard:
const urduInput = document.getElementById('myInput');
const urduKeyboard = document.getElementById('urduKeyboard');

    for (const key in urduPhoneticMap) {
        const button = document.createElement('button');
        button.className = 'keyboard-button';
        button.textContent = urduPhoneticMap[key];
        button.onclick = () => {
            if (key === 'backspace') {
                urduInput.value = urduInput.value.slice(0, -1);
            } else {
                urduInput.value += urduPhoneticMap[key];
            }
            urduInput.focus(); // Keep focus on the input field
        };
    
        urduKeyboard.appendChild(button);
    
}

// Here it is needed to add some code like ((document.getElementById("myInput").click();)) to make input box clicked automatically plus a similar code for Onkeyup function to generate key pressed automatically.



//Second virtual keyboard:
const arabicInput = document.getElementById('myInput2');
const keyboardContainer = document.getElementById('keyboardContainer');
const phoneticMap = {// keyboards buttons
// Create keyboard keys
function createKeyboard() {
    for (const phonetic in phoneticMap) {
        const keyElement = document.createElement('div');
        keyElement.classList.add('key');
        keyElement.textContent = phoneticMap[phonetic];
        keyElement.dataset.phonetic = phonetic; // Store phonetic value
        keyboardContainer.appendChild(keyElement);
    }
}

// Handle key clicks
keyboardContainer.addEventListener('click', (event) => {
    const target = event.target;
    if (target.classList.contains('key')) {
        const phoneticKey = target.dataset.phonetic;
        if (phoneticKey === 'backspace') {
            arabicInput.value = arabicInput.value.slice(0, -1);
        } else if (phoneticKey === 'enter') {
            arabicInput.value += 'n';
        } else {
            arabicInput.value += phoneticMap[phoneticKey];
        }
        arabicInput.focus(); // Keep focus on the input field
    }
});

// Initialize the keyboard
createKeyboard();

// Here it is needed to add some code like ((document.getElementById("myInput").click();)) to make input box clicked automatically plus a similar code for Onkeyup function to generate key pressed automatically.

In React, why does useRef need .current but useState doesn’t?

I understand that Hooks like useState and useRef are valuable because they allow the user to store and update data that persists through re-renders. In short, useState is for data that should trigger a re-render when it’s updated, while useRef is for data that should not trigger a re-render when updated.

Ref:

// create
const count = useRef(0);
// write
count.current = 5;
// read
console.log(count.current);

State variable:

//create 
const [count, setCount] = useState(0);
// write
setCount(5);
// read
console.log(count);

Is there a design reason why the creators of React made it so reading the persistent value associated with a ref requires .current but reading the persistent value associated with a state variable doesn’t? I’m guessing there’s a good reason for it, but I have not been able to find the answer. Thank you for helping me to better understand.