Загрузка...

Why did React stop seeing the block?

Thread in Web development created by SleGka Dec 26, 2024. 139 views

  1. SleGka
    SleGka Topic starter Dec 26, 2024 Облизываю SUPERCELL 81 Dec 2, 2023
    Бля, это так забавно, вчера запускал этот код, все было без ошибок, а сейчас он не может найти блок по этому id
    Говорю конкретно про блок 'description-list'

    Текст ошибки: '
    chunk-FMOPAGIP.js?v=325cadc5:21168 Uncaught Error: createRoot(...): Target container is not a DOM element.
    at createRoot (chunk-FMOPAGIP.js?v=325cadc5:21168:19)
    at Object.createRoot$1 [as createRoot] (chunk-FMOPAGIP.js?v=325cadc5:21549:18)
    at exports.createRoot (react-dom_client.js?v=325cadc5:20:20)
    at main.jsx:7:19
    '

    HTML
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vite + React</title>
    </head>
    <body>
    <div class="dictionary-app">
    <h1 class="dictionary-app__header">Словарь</h1>

    <form id="add-description" class="form">
    <h2 class="form__title">Новый термин</h2>

    <label class="form-field">
    <span class="form-field__label">Термин</span>
    <input class="form-field__input" name="title" type="text" required />
    </label>

    <label class="form-field">
    <span class="form-field__label">Значение</span>
    <input class="form-field__input" name="description" type="text" />
    </label>

    <button class="form-button" type="submit">Запомнить</button>
    </form>

    <div id="description-list"></div>
    </div>

    <script type="module" src="./src/main.jsx"></script>
    </body>
    </html>
    JS
    import './index.css';

    const descriptionList = document.getElementById('description-list');
    const form = document.getElementById('add-description');
    console.log(descriptionList);

    form.addEventListener('submit', (event) => {
    event.preventDefault();

    const title = form.elements['title'].value;
    const description = form.elements['description'].value;

    form.reset();

    console.log(title, description);
    });
    че за тупость, где я провафлил?
     
Top
Loading...