Stand-alone, cross-component functions?
See original GitHub issueNewbie to Preact here ✨ Love how fast it is.
Is it possible to share stand-alone functions across various components? Several components in my preact app share functions that are unrelated to any particular components.
For example (I custom-built my own router):
routes/index.js
export const testForUrlRedirect = ({ url, props }) => {
...
return newUrl
}
export const getPageDataFromPageIdOrUrl = ({ pageId, url }) => {
...
return pageData
}
MyComponent.js
import { testForUrlRedirect, getPageDataFromPageIdOrUrl } from '../routes'
In MyComponent
, neither functions work as expected.
I did notice #722, yet that issue refers to functions that are part of other components. Is it possible to have stand-alone functions and share them across various components?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Getting started with standalone components - Angular
Standalone components provide a simplified way to build Angular applications. Standalone components, directives, and pipes aim to streamline the authoring ...
Read more >React Function Components
Everything you need to know about React Function Components -- also known as React Functional Components. Here you will learn React Function ......
Read more >Angular — Four Ways for Communication Between Components
Instead of establishing a direct linkage between components, a standalone injectable (service) is used as a middleman between them.
Read more >What is a Standalone Component in Angular - YouTube
GitHub Linkhttps://github.com/TheDotNetOffice/Angular-15-Tutorial-Classhttp://www.dotnetoffice.com/Support ...
Read more >Angular2 - call a function from another standalone component ...
I'm loading in a component (Component1) another standalone component(Component2) that contains a form. Imagine you have made a form component ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A bit of a more fitting explanation
Thanks @JoviDeCroock 👌