Code Monkey home page Code Monkey logo

Comments (10)

Angelk90 avatar Angelk90 commented on May 24, 2024 1

@okwasniewski , @Saadnajmi : Maybe I managed to do something, I replied on react-native-macos.

from react-native-menubar-extra.

okwasniewski avatar okwasniewski commented on May 24, 2024

Hey, so according to this stackoverflow thread you can use this library to achive it in React Native. However this is way out of scope for react-native-menubar-extra library, therefore I'm closing this issue.

from react-native-menubar-extra.

Angelk90 avatar Angelk90 commented on May 24, 2024

@okwasniewski : I tried to make it work, but I couldn't.

Screenshot 2023-09-28 alle 22 31 32 Screenshot 2023-09-28 alle 22 31 54
import {spawn, kill} from 'react-native-childprocess'

  useEffect(() => {
    const fetchData = async () => {
      cmdID = await spawn('/sbin/ping', ['google.com'], {
          pwd: "/",
          stdout: (output) => {
              console.log('>>>', output)
          }
      });
      console.log(cmdID)
    }
  
    fetchData()
      .catch(console.error);
  }, [])

from react-native-menubar-extra.

okwasniewski avatar okwasniewski commented on May 24, 2024

It works for me did you ran pod install after installing this library?

from react-native-menubar-extra.

Angelk90 avatar Angelk90 commented on May 24, 2024

@okwasniewski : it stops working.

Screenshot 2023-09-28 alle 22 52 28

from react-native-menubar-extra.

okwasniewski avatar okwasniewski commented on May 24, 2024

You need to clean up the old build. Inside macos folder run rm -rf Pods build and then install pods again (pod install)

from react-native-menubar-extra.

Angelk90 avatar Angelk90 commented on May 24, 2024

@okwasniewski : I don't understand why it's always macos from all these problems.

the first time it was worth:
console.log('o:', cmdID);
then changed it by saving it, then it updated:
console.log('oo:', cmdID);
I tried this:

useEffect(() => {
    let cmdID;
    const shell = async () => {
      cmdID = await spawn('pwd', ['-LP'], {
        pwd: '/Users',
        stdout: (output) => {
          console.log('stdout:', output);
        },
        stderr: (output) => {
          console.log('stderr:', output);
        },
        terminate: (output) => {
          console.log('terminate:', output);
        },
      });
      console.log('oo:', cmdID);
    };

    shell().catch(console.error);
    return () => {
      console.log("kill")
      kill(cmdID);
    };
  }, []);

But the command written this way seems to work well, I get this:

 LOG  o: -1
 LOG  kill
 LOG  [Error: invalid cmdID]
 LOG  oo: -1

from react-native-menubar-extra.

Saadnajmi avatar Saadnajmi commented on May 24, 2024

See my explanation here: microsoft/react-native-macos#1937 (comment)

It's not currently possible to run arbitrary node native modules with React Native macOS, as they have two completely separate methods of JS->Native (C++) communication.

from react-native-menubar-extra.

okwasniewski avatar okwasniewski commented on May 24, 2024

@Saadnajmi The solution for this particular issue would be to create an RN Macos library that would wrap another native library to execute shell commands like https://github.com/JohnSundell/ShellOut right?

from react-native-menubar-extra.

Saadnajmi avatar Saadnajmi commented on May 24, 2024

@Saadnajmi The solution for this particular issue would be to create an RN Macos library that would wrap another native library to execute shell commands like https://github.com/JohnSundell/ShellOut right?

Yep, unless the other project I mentioned lands and we can get all node native modules to "just work" with react native macOS (while using Hermes). But you know, that's a ways away I think, and writing your own native module OS the way to go IMO

from react-native-menubar-extra.

Related Issues (7)

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.