react-albus
react-albus copied to clipboard
Migration to React 16.x context
Hello, thanks for the great library.
Is it planned to migrate to the latest React versions, especially using stable context API?
As for React 16.x context, I created my own WizardContext which allows my code to get the albus context via the new 16.x API:
// WizardContext.tsx
import React from "react";
import PropTypes from 'prop-types';
import { WizardContext as AlbusContext } from 'react-albus';
export const WizardContext = React.createContext<AlbusContext>(
{} as AlbusContext
);
export const WizardProvider: React.FC = ({children}, context) => {
return (
<WizardContext.Provider value={context.wizard}>
{children}
</WizardContext.Provider>
);
};
WizardProvider.contextTypes = {
wizard: PropTypes.object
};
Then in the wizard tsx:
import { WizardProvider } from './WizardContext';
// ...
<Wizard>
<WizardProvider>
<Steps>
// ...
Then in a child component tsx:
import { WizardContext } from '../contexts/WizardContext';
// ...
const {
next
} = useContext(WizardContext);
// ...
<button onClick={next}>Next</button>
Hope this helps. Still hoping 16.x context support will be added soon.
This issue is stale because it has been open 30 days with no activity. Remove no-issue-activity label or comment or this will be closed in 5 days.
I have the same problem, it is important to do the migration!
@cheungpat is a good "solution", but it's only temporary
This issue is stale because it has been open 30 days with no activity.
sorry for the late response here. We'll be updating to the latest React Context api soon
I have the same problem too, is it still supposed to be fixed soon ? Thanks !
Hey I am also getting this warning - would be great to have an update!
@ryhinchey Any news?
This issue is stale because it has been open 30 days with no activity.
Hello, what has happened to this? Still getting this error.
This issue is stale because it has been open 30 days with no activity.