-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript add dynamic property #2691
Comments
You can do this
OR
|
I now have this in the import {ThemeManager, Colors} from 'react-native-ui-lib';
import type { ViewProps } from 'react-native-ui-lib'
interface CustomViewProps {
wrap?: boolean
}
Colors.loadDesignTokens({
primaryColor: Colors.blue40
});
const _colors = {
screenBG: 'white',
textColor: Colors.grey10,
moonOrSun: Colors.yellow30,
mountainForeground: Colors.green30,
mountainBackground: Colors.green50,
$backgroundSuccess: Colors.green40,
$backgroundSuccessLight: Colors.green70
}
Colors.loadSchemes({
light: _colors,
dark: _colors
});
ThemeManager.setComponentTheme('View', (props: ViewProps & CustomViewProps, context: any) => {
if (props.wrap) {
return {
justifyContent: 'flex-start',
alignItems: 'flex-start',
flexDirection: 'row',
flexWrap: 'wrap',
}
}
});
ThemeManager.setComponentForcedTheme('Card', {
borderRadius: 15,
padding: 15
})
ThemeManager.setComponentTheme('Incubator.TextField', (props: any, context: any) => {
return {
'text50': true,
'color': 'grey',
}
});
ThemeManager.setComponentTheme('Button', () => {
return {
}
}); And I load it in the import * as React from 'react';
import { Provider } from 'react-redux';
import { store } from './src/redux/store';
import RootNavigator from './src/screens/RootNavigator';
import "./src/services";
import "./src/themeManager"
const App = () => {
return (
<Provider store={store}>
<RootNavigator />
</Provider>
);
}
export default App; |
Sorry, my answer was not complete. I am not having this issue because I use a custom theme Component like this
|
I'm running into these typescript errors on the Since the ThemeManager has allowed passing custom props there should be a way to pass those props directly to UILib components without typescript errors. If there's no customization or overrides system provided out of the box, then the types should at least be defined as interfaces (instead of types) so that type augmentation can be done. |
It is worth noting that the main README of this project contains an example of adding a custom prop
|
tagging to get guidance on how to handle this issue. Currently blocked from upgrading past 7.6.2 as a result |
@nitzanwix @wixmobile @haim-wix @lidord-wix can someone please at least respond? |
Hi @bhandanyan-nomad More solutions we've been thinking of but still requires investigation and development are
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
How can I add a dynamic property to components so no editor errors are shown
Related to
Steps to reproduce
Add dynamic prop:
Result is error in VS Code:
Expected behavior
No error.
Actual behavior
Error shown.
The text was updated successfully, but these errors were encountered: