Giter VIP home page Giter VIP logo

Comments (5)

pepf avatar pepf commented on May 14, 2024 1

Seems to work! 👌

from react-nodegui.

elviosak avatar elviosak commented on May 14, 2024

i have a similar problem, when adding values to an array and using map to render Text elements, it doesnt get updated when adding or removing items, but it updates on next click(either adding or removing, but it stays one cycle behind), also updates if i click another button unrelated to the array..

this is my component (if the text on update button doesn't change it won't update)

const geometry = { x: 0, y: 100, width: 400, height: 600 };
function App() {
  const [update, setUpdate] = useState(true);
  const [textArr, setTextArr] = useState([]);
  const addItem = () => {
    const newText = Math.random()
      .toString(36)
      .substr(2, 5);
    setTextArr([...textArr, newText]);
  };
  const removeItem = () => {
    const newArr = Object.assign([], textArr);
    newArr.shift();
    setTextArr(newArr);
  };
  const updater = () => {
    setUpdate(!update);
  };
  return (
    <Window geometry={geometry} styleSheet={styleSheet}>
      <View>
        <Button
          on={{ clicked: updater }}
          text={update ? "update" : " update "}
        />
        <Button on={{ clicked: addItem }} text="Add Item" />
        <Button on={{ clicked: removeItem }} text="Remove Item" />
        <Text>{"stringified: " + JSON.stringify(textArr)}</Text>
        {textArr.map((txt) => (
          <Text key={txt}>{"text: " + txt}</Text>
        ))}
      </View>
    </Window>
  );
}

versions:

"@nodegui/nodegui": "^0.1.7",
"@nodegui/react-nodegui": "^0.1.6",

from react-nodegui.

a7ul avatar a7ul commented on May 14, 2024

This issue is now fixed in v0.1.9 of nodegui and react-nodegui

@pepf @slidinghotdog
Let me know if it fixes it after upgrading

from react-nodegui.

elviosak avatar elviosak commented on May 14, 2024

@master-atul its working great now, thanks!

from react-nodegui.

a7ul avatar a7ul commented on May 14, 2024

Awesome 🚀

from react-nodegui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.