Relative Content

Tag Archive for javascriptreactjsreact-nativereact-hooks

How to make a structure that has a method to return a way of printing jsx and another method to get the values used inside?

So I’ve been trying to make something like a copy of word where you can insert TextInputs to write and I also want to be able to add paragraph(windows in which you can put again other TextInputs to be seen better by someone who reads it), I have experimented with react-native Javascript but my efforts prove futile because I ether get an error which I cannot explain(something about hooks) or the fact that everything that is returned is undefied.
I have also tried with the old way(I mean with classes and states) but it’s no good either since even if I create a react class to print whatever I want I have to type <MyClass/> but this method doesn’t give me any information from inside the class or I can try the “new MyClass” but this cannot be printed to the screen since I cannot access the render method cause it’s called only if the class is declared as a react component(I mean this <MyClass/>) so my question is: Can i make any type of structure that can make use of the hooks so it can update automatically once changed, but also to have two methods one in which I can print jsx however I like it to be printed to the screen but also a method that can return me the data that is used by the hooks inside the structure I want to make?(for anyone wondering I want the data that is printed to the screen so I can transform it in a pdf file)

Why the obj is being logged twice in app component addnote function

import React from “react”; import Header from “./Header”; import Footer from “./Footer”; import Note from “./Note”; import CreateArea from “./CreateArea”; function App() { function addnote(obj) { console.log(obj); } return ( <div> <Header /> <CreateArea addnote={addnote} /> <Note key={1} title=”Note title” content=”Note content” /> <Footer /> </div> ); } export default App; this is my app […]

useState doesn’t update values

In short, worked quietly, but then wrote a couple of lines of code for an image that is not even related to useState just broke, other pages use the same methods as here, but they work there. I can’t explain exactly why this happens, probably due to repetition, where the first time it turns out to change the value, but then the second time it goes back to the standard value. I made this conclusion only because of the repetition in the console when I change the meaning in the text.